/*
 * joesERP系统功能扩展插件
 * ver 25.11.19
 * @createTime 2024年5月17日
 */
(function () {
    importJS('https://gitee.com/joeonehe/ruoteng/raw/master/resources/static/js/clipboard.min.js');
    importJS('https://gitee.com/joeonehe/ruoteng/raw/master/resources/static/js/pxmu.min.js');
    importJS('https://gitee.com/joeonehe/ruoteng/raw/master/resources/static/js/math@13.2.0.js');
    importJS('https://gitee.com/joeonehe/ruoteng/raw/master/resources/static/js/getPinYin.js');
    importJS('https://gitee.com/joeonehe/ruoteng/raw/master/resources/static/js/sheet.min.js');

    // console.log("location: ", location);
    if (location.pathname == "/index.html") {
        var jerpFrame = document.createElement('div');
        jerpFrame.id = "jerpFrame";
        jerpFrame.innerHTML = `
        <el-row id="jerpBtn">
            <el-button round v-for="item in jerpData" v-show="item.status" @click="open(item.openTag)">{{item.name}}</el-button>
        </el-row>
        <div id="jerpWindow" v-show='showWindow'>
            <div class="btnFrame">
                <a title="关闭" class="btn jerp_btn close" @click="close('window')"><i>x</i></a>
            </div>
            <div class="jerpWindow_inner">
                <div class="inner_left"> <!--  @mouseleave="hideAllSub()" -->
                    <ul id="jerpMenu" class="mainMenu">
                        <li :class="{active:item.active}" v-for="(item,index) in winMenu" v-if="item.status">
                            <a @click="showSub(item)">{{item.name}}
                                <pre class="menuSubTitle" v-show="item.subName && item.subName!=''">\n{{item.subName}}</pre>
                            </a>
                            <div class="subMenu" v-if="item.child">
                                <ul>
                                    <li class="m_btn" v-for="(subItem,subIndex) in item.child" v-if="subItem.status">
                                        <a @click="openTab(subItem)">{{subItem.name}}
                                            <pre class="menuSubTitle" v-if="subItem.subName && subItem.subName!=''">\n{{subItem.subName}}</pre>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
                <div id="inner_right" class="inner_right">
                    <div id="jerpTitle" class="jerpTitle">
                        <span>{{winTitle.title}}</span>
                        <span class="subtitle">
                            <span>{{winTitle.subtitle != '' ? winTitle.subtitle : ''}}</span>
                            <span>{{winTitle.total > 0 ? ' (' : ''}}</span>
                            <span style="color:green;">{{winTitle.total > 0 && winTitle.selected != null ? winTitle.selected + ' / ' : ''}}</span>
                            <span style="color:blue;">{{winTitle.total > 0 && winTitle.total > 0 ? (winTitle.get + ' / ') : ''}}</span>
                            <span>{{winTitle.total > 0 ? winTitle.total : ''}}</span>
                            <span>{{winTitle.total > 0 ? ') ' : ''}}</span>
                            <span>{{winTitle.getTime}}</span>
                            <span>{{winTitle.otherContent != '' ? ' | ' + winTitle.otherContent : ''}}</span>
                        </span>
                    </div>
                    <div id="jerpContent" class="jerpContent" v-html="winContent"></div>
                </div>
            </div>
        </div>
        <div id="jerpNote" class="jerpSubwin" v-show='showNote' :style="{transform: 'translate('+ jerpSetting.note.clientX +'px,'+ jerpSetting.note.clientY +'px)'}">
            <div class="btnFrame">
                <a title="关闭" class="btn jerp_btn close" @click="close('note')"><i>x</i></a>
            </div>
            <div class="jerpSubwinTitle" @mousedown="notemousedown">备忘录</div>
            <div class="jerpSubwinContent">
                <textarea style="border-radius: 0.5rem;" v-model="jerpSetting.userInfos[jerpSetting.currentUser].note.content" @change="updateUserInfo"></textarea>
            </div>
        </div>
        <div id="jerpAftersaleRN" class="jerpSubwin" v-show='jerpSetting.aftersaleRN.status'>
            <!-- && jerpSetting.aftersaleRN.list.length>0 -->
            <div class="jerpSubwinTitle">退货订单信息</div>
            <div class="jerpSubwinContent">
                <div class="jerpSubwinContent_inner">
                    <div class="jerpRow" style="font-size: 1rem;">
                        <div class="jerpCol">
                            <span>仓库：</span>
                            <select style="width: 8rem;" v-model="jerpSetting.aftersaleRN.warehouse">
                                <option value="" disabled="true" selected="true">请选择仓库</option>
                                <option v-for="item in jerpSetting.aftersaleRN.warehouseList" :value="item.id">{{item.name}}</option>
                            </select>
                        </div>
                    </div>
                    <div class="jerpRow" style="font-size: 1rem;">
                        <div class="jerpCol">
                            <span>订单状态：</span>
                            <span style="font-weight: bold;" :style="{'color':jerpSetting.aftersaleRN.isError?'red':'green'}">
                                {{jerpSetting.aftersaleRN.sysStatus}}
                            </span>
                        </div>
                    </div>
                    <div class="jerpRow" style="font-size: 1rem;">
                        <div class="jerpCol">
                            <span>扣减库存：</span>
                            <span style="font-weight: bold;" :style="{'color':jerpSetting.aftersaleRN.isPicked?'green':'red'}">
                                {{jerpSetting.aftersaleRN.isPicked}}
                            </span>
                        </div>
                    </div>
                    <div class="jTable" v-show="jerpSetting.aftersaleRN.list.length>0">
                        <div class="jTable_title">
                            <div class="jTable_row">
                                <div class="jTable_col" style="flex: 1;"><span>序</span></div>
                                <div class="jTable_col" style="flex: 6;"><span>商品名称</span></div>
                                <div class="jTable_col" style="flex: 4;"><span>货位编码</span></div>
                            </div>
                        </div>
                        <div class="jTable_content">
                            <div class="jTable_content_c">
                                <div class="jTable_content_row" v-for="(item,index) in jerpSetting.aftersaleRN.list">
                                    <div class="jTable_row" @click="subContentShow(item)">
                                        <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                        <div class="jTable_col" style="flex: 6;"><span>{{item.title}}</span></div>
                                        <div class="jTable_col" style="flex: 4;"><span>{{item.code}}</span></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="jerpBG" v-show="showWindow || showNote" @click="close()"></div>
        <div class="priviewFrame" v-show="priview.focusA || priview.focusB" :style="{transform: 'translate('+ priview.x +'px,'+ priview.y +'px)'}">
            <img id="jerpPriviewImg" class="jerpPriviewImg" :src="priview.src" :width="priview.width * priview.scale" :height="priview.height * priview.scale" />
        </div>`;
        document.body.appendChild(jerpFrame);
        var subVue = null;
        const jerp = new Vue({
            el: '#jerpFrame',
            data: {
                mainStockId: '62008', // 304567: 新仓, 62008: 管件, 288876: 备货
                delay: () => { let t = parseInt(Math.random() * 500); return t < 100 ? 100 : t },
                "winTitle": {
                    "title": '首页',
                    "subtitle": '',
                    "selected": '',
                    "get": 0,
                    "total": 0,
                    "getTime": null,
                    "otherContent": '',
                },
                winContent: `<span>请选择一个模块功能...</span>`, // 窗口模板
                showWindow: false,
                showNote: false,
                goodsCodeCache: {}, // 用于全局存放商品货位
                sysStatus: {
                    // 系统状态
                    'WAIT_AUDIT': '待审核',
                    'WAIT_FINANCE_AUDIT': '待财审',
                    'WAIT_EXPRESS_PRINT': '待打印快递单',
                    'WAIT_SEND_GOODS': '待发货',
                    'SELLER_SEND_GOODS': '卖家已发货',
                    'WAIT_PACKAGE': '待包装',
                    'FINISHED': '已完成',
                    'CANCEL': '作废',
                    'CLOSED': '关闭',
                    "WAIT_WEIGHT": "待称重",
                    // 商品状态
                    'FINISHED_AUDIT': '待发货',
                    // 平台状态
                    'WAIT_BUYER_CONFIRM_GOODS': '已发货',
                    'WAIT_SELLER_SEND_GOODS': '待发货',
                    // 采购单状态 purchaseStatus
                    'STATUS_WAIT_VERIFY': '草稿',
                    'STATUS_CLOSED': '已关闭',
                    'STATUS_FINISHED': '已完成',
                    'WAIT_VERIFY': '草稿',
                    'GOODS_CLOSED': '已关闭',
                    'VERIFYING': '待审核',
                },
                jerpSetting: {
                    currentUser: null,
                    note: {
                        clientX: 0,
                        clientY: 0,
                    },
                    userInfos: {
                    },
                    shortIdOver: null, // 交易，短号over，记录短号字符串
                    aftersaleRN: { // 售后，退货入仓，页面参数
                        sysStatus: '',
                        isPicked: '',
                        status: false,
                        isError: false,
                        list: [], // 显示的列表
                        goodsObj: {}, // 商品记录，避免重复获取
                        warehouseList: [], // 仓库列表
                        warehouse: "", // 当前选择的仓库
                    },
                    pca3level: {},
                },
                // 菜单
                jerpData: [
                    { // 插件
                        id: 'erpInterface',
                        name: 'ERP插件',
                        active: true,
                        status: false,
                        role: [],
                        openTag: 'window',
                        child: [
                            /**
                            { // 首页
                                name: '首页',
                                subName: '',
                                active: false,
                                status: false,
                                role: [],
                                init: function () {
                                    document.getElementById('jerpContent').innerHTML = `请选择一个模块功能...`;
                                    // subVue = new Vue({
                                    //     el: "#jerpContent",
                                    //     data: {
                                    //     },
                                    //     computed: {
                                    //     },
                                    //     methods: {
                                    //     }
                                    // })
                                }
                            },
                             */
                            { // 日常
                                name: '日常',
                                subName: '',
                                active: false,
                                status: false,
                                role: [],
                                child: [
                                    { // 低于成本价V2
                                        name: '低于成本价V2',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>截止订单</span>
                                                            <input v-model="orderInputStr" placeholder="输入系统单号"></input>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <a class="btn" @click="check()">查询</a>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <!-- <a class="btn copy" @click="btnExport('copy')">复制</a> -->
                                                        <a class="btn copy" @click="btnExport('excel')">导出</a>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>系统单号</span></div>
                                                                    <div class="jTable_col" style="flex: 3;"><span>内部短号</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>平台单号</span></div>
                                                                    <div class="jTable_col" style="flex: 3;"><span>订单来源</span></div>
                                                                    <div class="jTable_col" style="flex: 3;"><span>店铺名称</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>订单状态</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row" @click="subContentShow(item)">
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;"><span>{{item.code}}</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>{{item.shortId}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;"><span>{{item.memo}}</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>{{item.shopSourceName}}</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>{{item.shopName}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{sysStatusStr(item.sysStatus)}}</span></div>
                                                                        </div>
                                                                        <div class="jTable_sub" v-show="item.subShow">
                                                                            <div class="jTable_sub_inner">
                                                                                <div class="jTable_subTitle">
                                                                                    <div class="jTable_row">
                                                                                        <div class="jTable_col" style="flex:3"><span>商品名称</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>订单数量</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>单价</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>折后单价</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>成本单价</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>采购单价</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>采购单号</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>供应商</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>交货日期</span></div>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="jTable_subContent">
                                                                                    <div class="jTable_row" v-for="(subItem,subIndex) in item.child">
                                                                                        <div class="jTable_col" style="flex:3"><span>{{subItem.title}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.num}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.price}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.pay}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.cost}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.purchasePrice}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.purchaseNo}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.supplierName}}</span></div>
                                                                                        <div class="jTable_col" style="flex:1"><span>{{subItem.deliveryDate}}</span></div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    list: [],
                                                    orderInputStr: '',
                                                    "getTime": null, // jerp.getFormatDate(new Date()),
                                                    copyAvailable: true,
                                                },
                                                computed: {
                                                    sysStatusStr: function () {
                                                        return (sysStatus) => {
                                                            let str = jerp.sysStatus[sysStatus];
                                                            return str ? str : sysStatus;
                                                        }
                                                    }
                                                },
                                                methods: {
                                                    updateTitle: function (isProcessed, total) {
                                                        // jerp.winSubtitle = `( <span style="color:green;">${this.list.filter(e => { return e.isException && e.isShow }).length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.getTime}`;
                                                        // jerp.winSubtitle = `( <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.getTime}`;
                                                        if (isProcessed == total) {
                                                            jerp.pxmu.closeload();
                                                        }
                                                        jerp.winTitle.get = isProcessed;
                                                        jerp.winTitle.total = total;
                                                        jerp.winTitle.getTime = this.getTime;
                                                    },
                                                    subContentShow: function (item) {
                                                        item.subShow = !item.subShow;
                                                    },
                                                    check: function () {
                                                        this.getTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                        this.copyAvailable = false;

                                                        jerp.pxmu.showload('(1/3)获取订单...');
                                                        let self = this;
                                                        let startTime = Math.round(new Date(jerp.getFormatDate(new Date(), 'yyyy-MM-dd 00:00:00'))) - (24 * 60 * 60 * 1000) * 3;
                                                        // console.log(jerp.getFormatDate(new Date(startTime)));
                                                        jerp.getOrders({ // 不要带pageNo
                                                            api_name: 'trade_search',
                                                            useHasNext: 1,
                                                            queryId: 62,
                                                            order: 'desc',
                                                            _t: Math.round(new Date()),
                                                            timeType: 'pay_time',
                                                            tagIds: 1000000018, // 标签：单价异常
                                                            excludeTagIds: [1000000006, 1000000005, 4852919152027232].toString(),
                                                            dateTypeSelect: 0,
                                                            startTime: startTime, // 3天内
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            key: 'mainOuterId',
                                                            btasType: '待质检',
                                                            queryType: 1,
                                                            highlight: false,
                                                            field: 'pay_time',
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                        }, 200).then(orders => {
                                                            // console.log("orders: ", orders);
                                                            if (orders.length > 0) {
                                                                let purchaseList = {};
                                                                new Promise(resolve => {// 获取所有符合条件订单细
                                                                    let sids = [];
                                                                    for (let i = 0; i < orders.length; i++) {
                                                                        let h = orders[i];
                                                                        if (h.b == this.orderInputStr) {
                                                                            break;
                                                                        }
                                                                        // 订单只有1个商品的话，不用看
                                                                        // 速卖通目前看不到单价，所以也不看
                                                                        if (h.u > 1 && !(h.gt.indexOf('速卖通') > -1)) {
                                                                            // console.log("id: ", h.b);
                                                                            sids.push(h.b);
                                                                        }

                                                                        // if (sids.length > 3) break;
                                                                    }
                                                                    if (sids.length > 0) {

                                                                        // console.log("sids: ", sids);
                                                                        $.ajax({
                                                                            url: location.origin + '/trade/search/sids',
                                                                            method: 'post',
                                                                            dataType: 'json',
                                                                            data: {
                                                                                'api_name': 'trade_search_sids',
                                                                                order: 'desc',
                                                                                'sids': sids.toString(),
                                                                                field: 'pay_time',
                                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                                _t: Math.round(new Date()),
                                                                                withStock: true
                                                                            },
                                                                            success: function (e) {
                                                                                if (e && e.clueId && e.result == 1) {
                                                                                    resolve(e.data.list);
                                                                                } else {
                                                                                    jerp.pxmu.closeload(e.message);
                                                                                }
                                                                            },
                                                                            error: function () {
                                                                                jerp.pxmu.closeload('无法获取数据，请联系管理员！');
                                                                            }
                                                                        });
                                                                    } else {
                                                                        esolve([]);
                                                                    }
                                                                }).then(async (data) => { // 填充订单数据
                                                                    // console.log('orders_all: ', data);
                                                                    // return new Promise(resolve => {
                                                                    if (data.length > 0) {
                                                                        // 提取出所有复合条件的订单商品 - 去重
                                                                        let goodsList = {};
                                                                        for (let i = 0; i < data.length; i++) {
                                                                            let h = data[i];
                                                                            let ld = [];
                                                                            for (let j = 0; j < h.orders.length; j++) {
                                                                                let d = h.orders[j];
                                                                                if (d.title != '差价' &&
                                                                                    !((d.sysTitle.indexOf('球阀') > -1 && d.sysTitle.indexOf('DN15') > -1 && d.sysTitle.indexOf('DN150') < 0))
                                                                                ) {
                                                                                    if (!goodsList[d.outerId]) {
                                                                                        goodsList[d.outerId] = { outerId: d.outerId, title: d.title };
                                                                                        let p = await jerp.getLastPurchaseOrder(goodsList[d.outerId]);
                                                                                        goodsList[d.outerId] = {
                                                                                            ...goodsList[d.outerId], ...{
                                                                                                purchasePrice: p ? p.purchasePrice : '',
                                                                                                code: p ? p.code : '',
                                                                                                supplierName: p ? p.supplierName : '',
                                                                                                deliveryDate: p ? jerp.getFormatDate(new Date(p.deliveryDate)) : '',// 收货日期
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }

                                                                                // price: 单价
                                                                                // payment: 付款
                                                                                // cost: 成本单价
                                                                                let pay = parseFloat(d.payment) / d.num;
                                                                                let cost = d.cost; // 成本单价

                                                                                ld.push({
                                                                                    outerId: d.outerId, // 商家编码
                                                                                    title: d.title,// 商品名称
                                                                                    num: d.num, // 订单数量
                                                                                    price: d.price,// 单价
                                                                                    pay: pay,// 折后单价
                                                                                    cost: cost,// 成本单价
                                                                                    purchasePrice: !goodsList[d.outerId] ? '' : goodsList[d.outerId].purchasePrice,
                                                                                    purchaseNo: !goodsList[d.outerId] ? '' : goodsList[d.outerId].code,
                                                                                    supplierName: !goodsList[d.outerId] ? '' : goodsList[d.outerId].supplierName,
                                                                                    deliveryDate: !goodsList[d.outerId] ? '' : goodsList[d.outerId].deliveryDate,// 收货日期
                                                                                    isException: pay <= cost,
                                                                                });
                                                                            }
                                                                            let memo = []; for (let k in h.messageMemos) { memo.push(k); }
                                                                            if (ld.length > 0) {
                                                                                self.list.push({
                                                                                    code: h.sid,
                                                                                    shortId: h.shortId,
                                                                                    shopSourceName: h.shopSourceName,
                                                                                    shopName: h.shopName,
                                                                                    sysStatus: h.sysStatus,
                                                                                    memo: memo.toString(), // 平台订单号
                                                                                    child: ld,
                                                                                    subShow: false,
                                                                                    isException: ld.filter(e => e.isException).length > 0,
                                                                                });
                                                                            }
                                                                            self.updateTitle(i + 1, data.length);
                                                                        }
                                                                    } else {
                                                                        jerp.pxmu.closeload('没有异常数据哦~')
                                                                    }
                                                                    // });
                                                                });
                                                            } else {
                                                                jerp.pxmu.closeload('未找到相关数据...');
                                                            }
                                                        });
                                                        this.copyAvailable = true;
                                                    },
                                                    btnExport: function (type) {
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }

                                                        let content = '',
                                                            copyList = {
                                                                '_index': '序号',
                                                                'code': '系统单号',
                                                                'memo': '平台单号',
                                                                'shopName': '店铺名称',
                                                            },
                                                            copyListSub = {
                                                                'outerId': '商品编码',
                                                                'title': '商品名称',
                                                                'price': '单价',
                                                                'pay': '折后单价',
                                                                'num': '订单数量',
                                                                'cost': '成本单价',
                                                                'purchasePrice': '采购单价',
                                                                'purchaseNo': '采购单号',
                                                                'supplierName': '供应商',
                                                                'deliveryDate': '交货日期',
                                                            }
                                                        let exData = [], title = [];
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            title.push(copyList[i]);
                                                        }
                                                        for (let i in copyListSub) {
                                                            title.push(copyListSub[i]);
                                                        }
                                                        exData.push(title);
                                                        let indexNum = 0;
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let l = this.list[i];
                                                            if (l.child.length > 0) {
                                                                for (let j = 0; j < l.child.length; j++) {
                                                                    let row = [];
                                                                    let d = l.child[j];
                                                                    for (let a in copyList) {
                                                                        if (a == "_index") {
                                                                            row.push(j == 0 ? ++indexNum : "");
                                                                        } else {
                                                                            row.push(j == 0 ? l[a] : "");
                                                                        }
                                                                    }
                                                                    for (let b in copyListSub) {
                                                                        row.push(d[b]);
                                                                    }
                                                                    exData.push(row);
                                                                }
                                                            } else {
                                                                let row = [];
                                                                for (let a in copyList) {
                                                                    if (a == "_index") {
                                                                        row.push(++indexNum);
                                                                    } else {
                                                                        row.push(l[a]);
                                                                    }
                                                                }
                                                                exData.push(row);
                                                            }
                                                        }
                                                        if (type == 'excel') {
                                                            jerp.sheet.export(exData, '低于成本价v2');
                                                        }
                                                        if (type == 'copy') {
                                                            let content = '';
                                                            for (let i = 1; i < exData.length; i++) {
                                                                let row = exData[i];
                                                                for (let j = 0; j < row.length; j++) {
                                                                    let col = row[j];
                                                                    content += '"' + col + '"\t';
                                                                }
                                                                content += "\n";
                                                            }
                                                            jerp.copy(content);
                                                        }
                                                    },
                                                }
                                            })
                                        }
                                    },
                                    { // 发货v2
                                        name: '发货v2',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特', '云淡风轻'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>主仓：</span>
                                                            <select style="width: 8rem;" v-model="warehouse">
                                                                <option value="" disabled="true" selected="true">请选择仓库</option>
                                                                <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <span>标签：</span>
                                                            <select style="width: 8rem;" v-model="label">
                                                                <option value="" disabled="true" selected="true">请选择标签</option>
                                                                <option v-for="item in labelList" :value="item.id">{{item.tagName}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <input v-model="expressInputStr" placeholder="未发货快递单号"></input>
                                                            <i class="btnInner" @click="orderListsShow(true)">+</i>
                                                        </div> 
                                                        <div class="jerpCol">
                                                            <a class="btn" @click="setSpecifiedLabels()">{{setLabel}}</a>
                                                            <input type="datetime-local" v-model="checkTime"></input>
                                                            <a class="btn" @click="check()" :title="checkTime+'之前的已打印订单'">2.查询订单</a>
                                                            <a class="btn" @click="picking()">3.发货</a>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>筛选：</span>
                                                            <button class="btn filterBtn" :style="filter.express.typeList[filter.express.type].style" @click="filter_express">{{filter.express.typeList[filter.express.type].title}}</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <a class="btn copy" @click="copy('no')">复制单号</a>
                                                        <!--
                                                            <span>复制：</span>
                                                            <a class="btn copy" @click="copyShippable()">可发货</a>
                                                            <a class="btn copy" @click="copyUnpicked()">未拣选</a>
                                                        -->
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><input type="checkbox" @change="selectAll()" v-model="select.isSelectAll"></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 6;"><span>系统单号</span></div>
                                                                    <!-- <div class="jTable_col" style="flex: 4;"><span>内部短号</span></div> -->
                                                                    <div class="jTable_col" style="flex: 3;"><span>单据状态</span></div>
                                                                    <!-- <div class="jTable_col" style="flex: 7;"><span>快递模板</span></div> -->
                                                                    <div class="jTable_col" style="flex: 8;"><span>快递单号</span></div>
                                                                    <div class="jTable_col" style="flex: 7;"><span>打印</span></div>
                                                                    <!-- <div class="jTable_col" style="flex: 7;"><span>包装</span></div> -->
                                                                    <div class="jTable_col" style="flex: 8;"><span>最新物流</span></div>
                                                                    <div class="jTable_col" style="flex: 8;"><span>备注详情</span></div>
                                                                    <div class="jTable_col" style="flex: 8;"><span>系统备注</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content" style="min-height: 26.1rem;">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list_filter" @click="clickSelectTr(item,index)"> <!--  @click="subContentShow(item)" -->
                                                                        <div class="jTable_row" :style="{'background':(item.isSelected?'#76d1ff':'none')}">
                                                                            <div class="jTable_col" style="flex: 1;"><input type="checkbox" v-model="item.isSelected"></input></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{((jTable.footer.nowTab-1)*jTable.footer.showTabNum)+index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 6;"><span>{{item.code}}</span></div>
                                                                            <!-- <div class="jTable_col" style="flex: 4;"><span>{{item.shortId}}</span></div> -->
                                                                            <div class="jTable_col" style="flex: 3;"><span>{{item.status}}</span></div>
                                                                            <!-- <div class="jTable_col" style="flex: 7;"><span>{{item.logisticsCompanyName}}</span></div> -->
                                                                            <div class="jTable_col" style="flex: 8;"><span>{{item.outSid}}</span></div>
                                                                            <div class="jTable_col" style="flex: 7;"><span>{{item.dy}}</span></div>
                                                                            <!-- <div class="jTable_col" style="flex: 7;"><span>{{item.bz}}</span></div> -->
                                                                            <div class="jTable_col" style="flex: 8;"><span>{{item.expressDesc}}</span></div>
                                                                            <div class="jTable_col" style="flex: 8;"><span>{{item.remark}}</span></div>
                                                                            <div class="jTable_col" style="flex: 8;"><span>{{item.sysremark}}</span></div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_footer">
                                                                <div class="jerpRow">
                                                                    <div class="jerpCol">
                                                                        <div>共{{list.length}}条数据</div>
                                                                    </div>
                                                                </div>
                                                                <div class="jerpRow">
                                                                    <div class="jerpCol" style="margin-right: 1rem;">
                                                                        <div>
                                                                            <span>显示</span>
                                                                            <select v-model="jTable.footer.showTabNum">
                                                                                <option value="0">全部</option>
                                                                                <option value="10">10</option>
                                                                                <option value="50">50</option>
                                                                                <option value="100">100</option>
                                                                                <option value="200">200</option>
                                                                                <option value="500">500</option>
                                                                                <option value="1000">1000</option>
                                                                            </select>
                                                                            <span>数据</span>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jerpCol">
                                                                        <div class="jTable_footer_btn">
                                                                            <button :disabled="jTable.footer.nowTab<=1" @click="turnUp"><</button>
                                                                        </div>
                                                                        <div>
                                                                            <span>第</span>
                                                                            <input type="rel" v-model="jTable.footer.nowTabInput" @change="tableTurn"></input>
                                                                            <span>页/共{{jTable.footer.maxTab}}页</span>
                                                                        </div>
                                                                        <div class="jTable_footer_btn">
                                                                            <button :disabled="jTable.footer.nowTab>=jTable.footer.maxTab" @click="turnDown">></button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="multiInputShow">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>批量添加</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="orderListsShow(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner">
                                                    <div class="inputCol">
                                                        <textarea v-model="expressListsStr"></textarea>
                                                    </div>
                                                </div>
                                                <div class="selectFooter">
                                                    <a class="btn" @click="confirm()">确定</a>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "labelList": [],
                                                    "label": "",
                                                    "xc": 10,
                                                    "xcNum": 0,
                                                    "select": {
                                                        "isSelectAll": false,
                                                        "isShiftDown": false,
                                                        "lastSelectStatus": false,
                                                        "lastSelectIndex": 0,
                                                    },
                                                    "warehouse": "",
                                                    "warehouseList": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses,
                                                    checkPrev: {
                                                        prevItem: null,
                                                        status: false,
                                                    },
                                                    list: [],
                                                    pickList: [],
                                                    expressInputStr: '',
                                                    expressListsStr: [],
                                                    multiInputShow: false,
                                                    nowTime: null,
                                                    checkTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd') + ' 00:00:00',
                                                    copyAvailable: true,
                                                    // checkTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd') + ' 23:59:59',
                                                    filter: {
                                                        express: {
                                                            type: 0,
                                                            typeList: [{
                                                                title: '物流状态',
                                                                style: {
                                                                    'color': '#b3b2b2',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '有物流',
                                                                style: {
                                                                    'background': 'green',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '等待揽收',
                                                                style: {
                                                                    'background': '#2695fa',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '无物流',
                                                                style: {
                                                                    'background': 'red',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }]
                                                        },
                                                    },
                                                    "jTable": {
                                                        "footer": {
                                                            "showTabNum": 50,
                                                            "showTabList": [],
                                                            "nowTab": 1,
                                                            "nowTabInput": 1,
                                                            "maxTab": 0,
                                                        }
                                                    }
                                                },
                                                mounted: async function () {
                                                    let self = this;
                                                    document.addEventListener('keydown', function (e) {
                                                        if (e.keyCode == 16) {
                                                            if (self.select.isShiftDown) {
                                                                return;
                                                            }
                                                            self.select.isShiftDown = true;
                                                            console.log('down');
                                                        }
                                                    })
                                                    document.addEventListener('keyup', function (e) {
                                                        if (e.keyCode == 16) {
                                                            self.select.isShiftDown = false;
                                                            console.log('up');
                                                        }
                                                    })
                                                    this.warehouse = this.warehouseList[0].id;

                                                    let tagList = [],
                                                        tagDatas = await jerp.getData({
                                                            url: '/trade/tag/list',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            "api_name": "trade_tag_list",
                                                            "kind": 0
                                                        });
                                                    // console.log(tagDatas);
                                                    if (tagDatas.length > 0) {
                                                        for (let i = 0; i < tagDatas.length; i++) {
                                                            // console.log(tagDatas[i].type);
                                                            if (tagDatas[i].type == 0) {
                                                                tagList.push(tagDatas[i]);
                                                                if (tagDatas[i].tagName.includes("发货")) {
                                                                    self.label = tagDatas[i].id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.labelList = tagList;
                                                    this.init();
                                                },
                                                computed: {
                                                    canShippedStr: function () {
                                                        return (status) => {
                                                            return status ? '是' : '';
                                                        }
                                                    },
                                                    list_filter: function () {
                                                        // console.log('list_filter');
                                                        let self = this, sNum = 0,
                                                            // nowTab = self.jTable.footer.nowTab,
                                                            showTabNum = self.jTable.footer.showTabNum;
                                                        // console.log("showTabNum: ", showTabNum);
                                                        let filterList = self.list.filter(v => {
                                                            let f = self.isFilter(v);
                                                            if (v.isSlected) { sNum++; }
                                                            return f;
                                                        });
                                                        this.jTable.footer.maxTab =
                                                            this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(filterList.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.footer.nowTab > this.jTable.footer.maxTab) {
                                                            this.jTable.footer.nowTab = 1;
                                                            this.jTable.footer.nowTabInput = 1;
                                                        }
                                                        // console.log("showTabNum: ", showTabNum);
                                                        // console.log("nowTab: ", this.jTable.footer.nowTab, " / maxTab: ", this.jTable.footer.maxTab);
                                                        if (showTabNum == 0) {
                                                            // console.log("filterList: ", filterList.length);
                                                            // console.log("sNum: ", sNum);
                                                            if (filterList.length == sNum) {
                                                                self.select.isSelectAll = true;
                                                            } else {
                                                                self.select.isSelectAll = false;
                                                            }
                                                            return filterList;
                                                        } else {
                                                            let showList = [], sNum = 0;
                                                            for (let i = (this.jTable.footer.nowTab - 1) * showTabNum; i < this.jTable.footer.nowTab * showTabNum; i++) {
                                                                if (i >= filterList.length) break;
                                                                if (filterList[i].isSelected) { sNum++ }
                                                                showList.push(filterList[i]);
                                                            }
                                                            if ((showList.length > 0) &&
                                                                (showList.length == sNum)
                                                            ) {
                                                                self.select.isSelectAll = true;
                                                            } else {
                                                                self.select.isSelectAll = false;
                                                            }
                                                            return showList;
                                                        };
                                                    },
                                                    setLabel: function () {
                                                        if (this.labelList.length == 0 || this.expressInputStr == "" || this.label == "") {
                                                            return "1.清空标签";
                                                        } else {
                                                            return "1.设置标签";
                                                        }
                                                    },
                                                    // maxTab: function () {
                                                    //     return this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(this.list.length / this.jTable.footer.showTabNum);
                                                    // },
                                                },
                                                methods: {
                                                    init: function () {
                                                        this.list = [];
                                                        jerp.winTitle.selected = 0;
                                                    },
                                                    // 翻页
                                                    turnUp: function () {
                                                        this.jTable.footer.nowTabInput--;
                                                        this.tableTurn();
                                                        this.checkSelectStatus();
                                                    },
                                                    turnDown: function () {
                                                        this.jTable.footer.nowTabInput++;
                                                        this.tableTurn();
                                                        this.checkSelectStatus();
                                                    },
                                                    tableTurn: function () {
                                                        // let maxTab = this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(this.list.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.footer.nowTabInput < 1) {
                                                            this.jTable.footer.nowTabInput = 1;
                                                        }
                                                        if (this.jTable.footer.nowTabInput > this.jTable.footer.maxTab) {
                                                            this.jTable.footer.nowTabInput = this.jTable.footer.maxTab;
                                                        }
                                                        this.jTable.footer.nowTab = this.jTable.footer.nowTabInput;
                                                        this.checkSelectStatus();
                                                    },
                                                    // 过滤
                                                    isFilter: function (item) {
                                                        let flag = true,
                                                            expressType = this.filter.express.type;
                                                        if (
                                                            (expressType == 1 && (item.expressDesc == '' || item.expressDesc.includes('等待揽收'))) ||
                                                            (expressType == 2 && !item.expressDesc.includes('等待揽收')) ||
                                                            (expressType == 3 && item.expressDesc != '')
                                                        ) flag = false;

                                                        return flag;
                                                    },
                                                    filter_express: function () {
                                                        this.filter.express.type = this.filter.express.type + 1 < this.filter.express.typeList.length ? this.filter.express.type + 1 : 0;
                                                    },
                                                    // 更新标题
                                                    updateTitle: function (isProcessed, total) {
                                                        // <span style="color:green;">${this.pickList.length}</span> / 
                                                        // jerp.winSubtitle = `( <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        if (isProcessed == total) {
                                                            jerp.pxmu.closeload();
                                                        }
                                                        jerp.winTitle.get = isProcessed;
                                                        jerp.winTitle.total = total;
                                                        jerp.winTitle.getTime = this.nowTime;
                                                    },
                                                    // 子输入框
                                                    subContentShow: function () {
                                                        return;
                                                    },
                                                    orderListsShow: function (status) {
                                                        this.multiInputShow = status;
                                                    },
                                                    confirm: function () {
                                                        let express = jerp.strProcessing(this.expressListsStr);
                                                        this.expressInputStr = express;
                                                        this.orderListsShow(false);
                                                    },
                                                    // checkbox
                                                    clickSelectTr: function (item, index) {
                                                        if (this.select.isShiftDown) {
                                                            for (let i = this.select.lastSelectIndex; i <= index; i++) {
                                                                this.list_filter[i].isSelected = this.select.lastSelectStatus;
                                                            }
                                                            // this.select.lastSelectStatus = false;
                                                            this.select.lastSelectIndex = index;
                                                        } else {
                                                            let status = !item.isSelected;
                                                            item.isSelected = status;
                                                            this.select.lastSelectStatus = status;
                                                            this.select.lastSelectIndex = index;
                                                        }
                                                        this.checkSelectStatus();
                                                    },
                                                    selectAll: function () {
                                                        let isSelectAll = this.select.isSelectAll,
                                                            // nowTab = this.jTable.footer.nowTab,
                                                            showTabNum = this.jTable.footer.showTabNum,
                                                            data = this.list_filter,
                                                            length = showTabNum > 0
                                                                ? (showTabNum > data.length ? data.length : showTabNum)
                                                                : data.length;
                                                        for (let i = 0; i < length; i++) {
                                                            data[i].isSelected = isSelectAll;
                                                        }
                                                        this.checkSelectStatus();
                                                    },
                                                    checkSelectStatus: function () {
                                                        // console.log('checkSelectStatus');
                                                        let data = this.list_filter, showTabNum = this.jTable.footer.showTabNum;
                                                        if (showTabNum == 0) {
                                                            let sNum = 0;
                                                            for (let i = 0; i < data.length; i++) {
                                                                if (data[i].isSelected) {
                                                                    sNum++;
                                                                }
                                                            }
                                                            if (sNum == data.length) {
                                                                this.select.isSelectAll = true;
                                                            } else {
                                                                this.select.isSelectAll = false;
                                                            }
                                                        }
                                                        jerp.winTitle.selected = this.list.filter(v => { return v.isSelected }).length;
                                                        // if (showTabNum == 0) {
                                                        //     if (data.length == jerp.winTitle.selected) {
                                                        //         this.select.isSelectAll = true;
                                                        //     } else {
                                                        //         this.select.isSelectAll = false;
                                                        //     }
                                                        // }
                                                    },
                                                    // 查询等重要方法
                                                    check: function (orders = [], pageNo = 1) { // 查询订单
                                                        this.init();
                                                        this.copyAvailable = false;
                                                        this.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                        if (pageNo == 1) jerp.pxmu.showload();

                                                        let self = this;
                                                        let pageSize = 1000;
                                                        $.ajax({
                                                            url: location.origin + '/trade/search/print',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            data: {
                                                                api_name: "trade_search_print",
                                                                queryId: 28,
                                                                sys: true,
                                                                itemOrder: "single",
                                                                warehouseId: this.warehouse,
                                                                order: "desc",
                                                                pageNo: pageNo,
                                                                pageSize: pageSize,
                                                                useHasNext: 1,
                                                                // orderFields: "id,oid,goodsSectionCodes,sysRemark,sysOuterId",
                                                                field: "express_print_time",
                                                                needOrder: 0,
                                                                useCompress: 1,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                _t: Math.round(new Date()),
                                                                // fe_groupId: 37207,
                                                                queryType: 0,
                                                                key: 'itemTitle',
                                                                // insufficientRate: [0, 1, 2].toString(),
                                                                // tickExcep: 0,
                                                                // onlyContain: -1,
                                                                excludeTagIds: self.label,//3654052177370061, // 标签
                                                                // onlyOuterIdAndSysSkuIdType: 0,
                                                                sysStatus: "WAIT_PACKAGE,WAIT_WEIGHT,WAIT_SEND_GOODS,WAIT_DEST_SEND_GOODS",
                                                                timeType: 'pay_time', // 'express_print_time',
                                                                endTime: Math.round(new Date(self.checkTime)),
                                                                // itemContainNonConsign: 0,
                                                                // dateTypeSelect: 0,
                                                                // btasType: '待质检',
                                                            },
                                                            success: function (e) {
                                                                if (e && e.clueId && e.data.list) {
                                                                    if (e.data.list.length == pageSize) {
                                                                        orders = self.check([...orders, ...e.data.list], pageNo + 1);
                                                                    } else {
                                                                        self.func([...orders, ...e.data.list]);
                                                                    }
                                                                } else {
                                                                    self.func(orders);
                                                                }
                                                            },
                                                            error: function (error) {
                                                                console.log("error", error);
                                                            }
                                                        })
                                                    },
                                                    func: async function (orders) { // 查询订单事件
                                                        // console.log('orders: ', orders);
                                                        // return;
                                                        this.pickList = [];

                                                        let self = this;
                                                        if (orders.length == 0) {
                                                            this.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                            jerp.pxmu.toast('没有符合条件的订单');
                                                            return;
                                                        }

                                                        // this.copyAvailable = false;
                                                        let isProcessed = 0; // 已处理数量

                                                        for (let i = 0; i < orders.length; i++) {
                                                            // for (let i = 0; i < 1; i++) {
                                                            // while (1) {
                                                            //     await jerp.sleep(10);
                                                            //     if (self.xcNum < self.xc) {
                                                            //         break;
                                                            //     }
                                                            // }
                                                            // setTimeout(async () => {
                                                            //     self.xcNum++;

                                                            let d = orders[i];
                                                            let sid = d.b, sysStatus = jerp.sysStatus[d.cl], isSelected = false;
                                                            // sysStatus == '待发货' || 
                                                            if (d.f == '交易完成' || d.f == '交易成功') { // d.f == '已发货' || 
                                                                self.pickList.push(sid);
                                                            } else {
                                                                let od = await this.func_getOrderDetails(sid),
                                                                    isPicked = false,
                                                                    jx = [], bz = [], dy = [];
                                                                // console.log(od);
                                                                // return;
                                                                if (od.traces && od.traces.length > 0) {
                                                                    for (let j = 0; j < od.traces.length; j++) {
                                                                        let d = od.traces[j];
                                                                        let param = {
                                                                            operator: d.operator,
                                                                            content: d.content,
                                                                            operateTime: d.operateTime
                                                                        };
                                                                        if (d.action == "包装验货") {
                                                                            bz.push(param);
                                                                        }
                                                                        if (d.action.includes('拣选领单') || d.action.includes('安排拣选员')) {
                                                                            jx.push(param);
                                                                        }
                                                                        if (d.action.includes('打印快递单')) {
                                                                            dy.push(param);
                                                                        }
                                                                        if (d.content.includes('扣减货位库存')) {
                                                                            isPicked = true;
                                                                        }
                                                                    }
                                                                }
                                                                let desc = od.express && od.express.length > 0 ? od.express[od.express.length - 1].statusDesc : "";
                                                                isSelected = desc != ""
                                                                    // && !desc.includes('等待揽收')
                                                                    // && !desc.includes('彭中海')
                                                                    && !desc.includes('取件')
                                                                    && !desc.includes('揽收')
                                                                    && !desc.includes('温州转运中心')
                                                                    ? true : false
                                                                // od.express && od.express.length > 0
                                                                //     && !od.express[od.express.length - 1].statusDesc.includes('等待揽收')
                                                                //     && !od.express[od.express.length - 1].statusDesc.includes('彭中海')
                                                                //     ? true : false;
                                                                // 彭中海
                                                                self.list.push({
                                                                    "isSelected": isSelected,
                                                                    code: d.b,
                                                                    status: sysStatus,
                                                                    logisticsCompanyName: d.logisticsCompanyName,
                                                                    shortId: d.shortId,
                                                                    outSid: d.y,
                                                                    expressDesc: od.express && od.express.length ? od.express[od.express.length - 1].statusDesc : '',
                                                                    jx: jx.length > 0 ? jx[0].operator + '\n' + jerp.getFormatDate(new Date(jx[0].operateTime), 'MM-dd HH:mm') : '',
                                                                    bz: bz.length > 0 ? bz[0].operator + '\n' + jerp.getFormatDate(new Date(bz[0].operateTime), 'MM-dd HH:mm') : '',
                                                                    dy: dy.length > 0 ? '【' + dy.length + '】 ' + jerp.getFormatDate(new Date(dy[0].operateTime), 'MM-dd HH:mm') : '',
                                                                    message: d.ad ? d.ad : '', // 留言详情 - buyerMessage
                                                                    remark: d.ae ? d.ae : '', // 备注详情 - sellerMemo
                                                                    sysremark: d.cm ? d.cm : '', // 系统备注 - sysMemo
                                                                });

                                                                // jerp.sleep();
                                                            }

                                                            self.updateTitle(++isProcessed, orders.length);
                                                            if (isSelected) jerp.winTitle.selected++;
                                                            // self.xcNum--;
                                                            // }, 0);
                                                        }
                                                        this.copyAvailable = true;
                                                    },
                                                    func_getOrderDetails: function (sid) {
                                                        return new Promise(resolve => {
                                                            let orderDetails = {
                                                                traces: [],
                                                                express: []
                                                            };
                                                            $.ajax({
                                                                url: location.origin + '/trade/detail',
                                                                method: 'get',
                                                                dataType: 'json',
                                                                async: false,
                                                                data: {
                                                                    api_name: 'rade_trace_detail',
                                                                    sid: sid
                                                                },
                                                                success: function (e) {
                                                                    if (e && e.clueId) {
                                                                        let taobaoId = e.data.taobaoId;
                                                                        let tid = e.data.tid;
                                                                        orderDetails.traces = e.data.traces;
                                                                        $.ajax({
                                                                            url: location.origin + '/trade/logistics/trace/search',
                                                                            method: 'get',
                                                                            dataType: 'json',
                                                                            async: true,
                                                                            data: { 'sid': sid, 'taobaoId': taobaoId, 'tid': tid },
                                                                            success: function (e) {
                                                                                if (e && e.clueId) {
                                                                                    let traceList = e.data[0].traceList;
                                                                                    if (traceList && traceList.length > 0) {
                                                                                        orderDetails.express = traceList;
                                                                                        resolve(orderDetails);
                                                                                    } else {
                                                                                        resolve(orderDetails);
                                                                                    }
                                                                                } else {
                                                                                    jerp.pxmu.toast('错误：请联系管理员！');
                                                                                    resolve(orderDetails);
                                                                                }
                                                                            },
                                                                            error: function () {
                                                                                resolve(orderDetails);
                                                                            }
                                                                        });
                                                                    } else {
                                                                        jerp.pxmu.toast('错误：请联系管理员！');
                                                                        resolve(orderDetails);
                                                                    }
                                                                },
                                                                error: function () {
                                                                    resolve(orderDetails);
                                                                }
                                                            });
                                                        });
                                                    },
                                                    copyShippable: function () {
                                                        if (this.list.length > 0) {
                                                            let content = '';
                                                            for (let i = 0; i < this.list.length; i++) {
                                                                let l = this.list[i];
                                                                // if (l.canShipped && l.outSid != '') {
                                                                if (l.canShipped) {
                                                                    content += l.code + '\n';
                                                                }
                                                            }
                                                            jerp.copy(content);
                                                        } else {
                                                            jerp.pxmu.toast('请先获取数据...');
                                                        }
                                                    },
                                                    copyUnpicked: function () { // 未拣选 isPicked: false
                                                        if (this.list.length > 0) {
                                                            let content = '';
                                                            for (let i = 0; i < this.list.length; i++) {
                                                                let l = this.list[i];
                                                                if (l.pickPersonName == '') {
                                                                    content += l.code + '\n';
                                                                }
                                                            }
                                                            jerp.copy(content);
                                                        } else {
                                                            jerp.pxmu.toast('请先获取数据...');
                                                        }
                                                    },
                                                    setSpecifiedLabels: function () { // 设置标签
                                                        jerp.pxmu.showload();
                                                        let msg = '标签设置错误，请联系管理员!';
                                                        // 先获取一下现在的打单未发货订单
                                                        let orders = jerp.getOrdersWithSpecifiedLabels(this.label);
                                                        if (orders.length > 0) {
                                                            let sids = [];
                                                            for (let i = 0; i < orders.length; i++) {
                                                                sids.push(orders[i].b);
                                                            }
                                                            // 然后清空标签
                                                            let suc = jerp.OrderSpecifiedLabelsClearAll(sids.toString(), this.label);
                                                            if (suc) msg = '标签已清空!';
                                                        } else {
                                                            msg = '未查询到指定标签的订单!';
                                                        }

                                                        if (this.expressInputStr == '') {
                                                            // jerp.pxmu.toast('请先输入查询的数据...');
                                                            // return;
                                                        } else {
                                                            // 将输入的快递单对应的订单，设置为打单未发货
                                                            orders = this.getOrderWithExpress();
                                                            if (orders.length > 0) {
                                                                let sids = [];
                                                                for (let i = 0; i < orders.length; i++) {
                                                                    sids.push(orders[i].b);
                                                                }
                                                                let suc = jerp.OrdersAddSpecifiedLabels(sids.toString(), this.label);
                                                                if (suc) msg = '标签设置完毕!';
                                                            } else {
                                                                msg = '';
                                                            }
                                                        }
                                                        jerp.pxmu.closeload(msg);
                                                    },
                                                    getOrderWithExpress: function (pageNo = 1, list = []) { // 通过快递获取订单
                                                        let self = this;
                                                        $.ajax({
                                                            url: location.origin + '/trade/search',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            async: false,
                                                            data: {
                                                                api_name: 'trade_search',
                                                                useHasNext: 1,
                                                                queryId: 62,
                                                                order: 'desc',
                                                                pageNo: pageNo,
                                                                pageSize: 50,
                                                                sid: '',
                                                                // shortId: 
                                                                // tid: 
                                                                // uniqueCodes: 
                                                                timeType: 'pay_time',
                                                                dateTypeSelect: 0,
                                                                // startTime: 
                                                                // endTime: 
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                outSid: this.expressInputStr,
                                                                // buyerNick: 
                                                                key: 'itemTitle',
                                                                // itemType: 
                                                                // text: 
                                                                // skuProp: 
                                                                // platSkuProp: 
                                                                // itemTitle: 
                                                                btasType: '待质检',
                                                                // userId: 
                                                                // secondUserId: 
                                                                // warehouseId: 
                                                                _t: Math.round(new Date()),
                                                                queryType: 1,
                                                                highlight: false,
                                                                field: 'pay_time',
                                                                needOrder: 0,
                                                                useCompress: 1
                                                            },
                                                            success: function (e) {
                                                                //成功触发
                                                                if (e && e.clueId) {
                                                                    if (e.data.list && e.data.list.length > 0) {
                                                                        list = self.getOrderWithExpress(pageNo + 1, [...list, ...e.data.list]);
                                                                    }
                                                                }
                                                            },
                                                            error: function (error) {
                                                                //失败，触发
                                                                console.log("error", error);
                                                            }
                                                        })
                                                        return list;
                                                    },
                                                    picking: function () { // 发货
                                                        if (!this.copyAvailable) {
                                                            jerp.pxmu.toast('请等待数据处理完成...');
                                                            return;
                                                        }
                                                        if (this.pickList.length + this.list.length == 0) {
                                                            jerp.pxmu.toast('请先获取数据...');
                                                            return;
                                                        }

                                                        let self = this;
                                                        jerp.pxmu.showload();
                                                        let sids2 = [];
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            if (this.list[i].isSelected) {
                                                                sids2.push(this.list[i].code);
                                                            }
                                                        }
                                                        let sids = [...this.pickList, ...sids2];
                                                        $.ajax({
                                                            url: location.origin + '/trade/consign/audited',
                                                            method: 'POST',
                                                            dataType: 'json',
                                                            // async: false,
                                                            data: {
                                                                api_name: 'trade_consign_audited',
                                                                // sid: [4869981163790605, 4869918572026752, 4869940325079664].toString(),
                                                                sids: sids.toString(),
                                                            },
                                                            success: function (e) {
                                                                if (e && e.clueId) {
                                                                    if (e.data.status == "success") {
                                                                        jerp.pxmu.closeload('发货成功处理中，请等待处理完成...', 10000);
                                                                        // self.check();
                                                                        // self.list = [];
                                                                        self.pickList = [];
                                                                        self.list = self.list.filter(e => { return !e.isSelected });
                                                                    } else {
                                                                        jerp.pxmu.closeload('发货失败，请联系管理员');
                                                                    }
                                                                }
                                                            },
                                                            error: function () {
                                                                jerp.pxmu.closeload('发货失败，请联系管理员');
                                                            }
                                                        });

                                                        // return status;

                                                    },
                                                    copy: function (type) {
                                                        if (!this.copyAvailable) {
                                                            jerp.pxmu.toast('数据获取中，请稍后再试……');
                                                            return;
                                                        }
                                                        switch (type) {
                                                            case 'no': {
                                                                // console.log('this.list: ', this.list);
                                                                let list = this.list.filter(v => { console.log(v.code, "_isSelected: ", v.isSelected, v); return v.isSelected });
                                                                console.log('list:', list);
                                                                let data = [], dataStr = '';
                                                                for (let i = 0; i < list.length; i++) {
                                                                    dataStr += list[i].code + '\n';
                                                                    // data.push([list[i].code]);
                                                                }
                                                                if (dataStr.length > 0) {
                                                                    jerp.copy(dataStr);
                                                                    // jerp.sheet.export(data, '发货导出');
                                                                } else {
                                                                    jerp.pxmu.toast('请勾选需要导出的数据！');
                                                                }
                                                                break;
                                                            }
                                                            default: {
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            })
                                        }
                                    },
                                    { // 查询：报货订单
                                        name: '查询：报货订单',
                                        subName: '商品缺货数量',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <input v-model="orderInputStr" placeholder="输入系统单号"></input>
                                                            <i class="btnInner" @click="orderListsShow(true, 'order')">+</i>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <input v-model="expressInputStr" placeholder="输入快递单号"></input>
                                                            <i class="btnInner" @click="orderListsShow(true, 'express')">+</i>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                            <!-- <button class="btn" @click="check_outStockOrder()">缺货异常</button> -->
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <!-- <button class="btn" @click="download()">↓</button> -->
                                                        <button class="btn copy" @click="copy2Excel(true)">导出全部</button>
                                                        <button class="btn copy" @click="copy2Excel()">导出缺货订单</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 3;"><span>内部短号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>订单状态</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>打印日期</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>物流单号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>库存充足</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row" @click="subContentShow(item)">
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span><span v-show="item.isBG">【空】</span>{{item.shortId}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.sysStatus}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;"><span>{{item.printTime}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;"><span>{{item.outSid}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{inStockStr(item.inStock)}}</span></div>
                                                                        </div>
                                                                        <div class="jTable_sub" v-show="item.subShow">
                                                                            <div class="jTable_subTitle">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex:3"><span>商品名称</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>订单数量</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>缺货数量</span></div>
                                                                                    <div class="jTable_col" style="flex:2"><span>采购单号</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>供应商</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>库存充足</span></div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_subContent">
                                                                                <div class="jTable_row" v-for="(subItem,subIndex) in item.child">
                                                                                    <div class="jTable_col" style="flex:3"><span><span v-show="subItem.isSuits">【套】</span>{{subItem.title}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.num}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.outNum}}</span></div>
                                                                                    <div class="jTable_col" style="flex:2"><span>{{subItem.purchaseNo}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.supplierName}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{inStockStr(subItem.inStock)}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="multiInputShow">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>批量添加</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="orderListsShow(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner">
                                                    <div class="inputCol" style="top: -0.8rem !important;right: -1rem !important;">
                                                        <textarea v-model="multiStr"></textarea>
                                                    </div>
                                                </div>
                                                <div class="selectFooter">
                                                    <a class="btn" @click="confirm()">确定</a>
                                                </div>
                                            </div>
                                            `;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    copyAvailable: true,
                                                    multiInputShow: false,
                                                    orderInputStr: '',
                                                    expressInputStr: '',
                                                    multiSelectType: '',
                                                    multiStr: '',
                                                    list: [],
                                                    nowTime: null,
                                                },
                                                computed: {
                                                    statusStr: function () {
                                                        return (status) => {
                                                            return jerp.sysStatus[status];
                                                        }
                                                    },
                                                    inStockStr: function () {
                                                        return (isStock) => {
                                                            return isStock ? '是' : '';
                                                        }
                                                    },
                                                },
                                                methods: {
                                                    init: function () {
                                                        this.list = [];
                                                        this.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                    },
                                                    updateTitle: function (isProcessed, total) {
                                                        // jerp.winSubtitle = `( <span style="color:green;">${this.list.filter(e => !e.inStock).length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        if (isProcessed == total) {
                                                            jerp.pxmu.closeload();
                                                        }
                                                        jerp.winTitle.get = isProcessed;
                                                        jerp.winTitle.total = total;
                                                        jerp.winTitle.getTime = nowTime;
                                                    },
                                                    orderListsShow: function (status, type) {
                                                        this.multiSelectType = type;
                                                        let multiStrList = [];
                                                        switch (type) {
                                                            case 'order': {
                                                                multiStrList = this.orderInputStr.split(',');
                                                                break;
                                                            }
                                                            case 'express': {
                                                                multiStrList = this.expressInputStr.split(',');
                                                                break;
                                                            }
                                                        }
                                                        if (multiStrList.length > 0) {
                                                            let multiStr = '';
                                                            for (let i = 0; i < multiStrList.length; i++) {
                                                                if (multiStrList[i] != "") {
                                                                    multiStr += multiStrList[i] + '\n';
                                                                }
                                                            }
                                                            this.multiStr = multiStr;
                                                        }
                                                        this.multiInputShow = status;
                                                    },
                                                    confirm: function () {
                                                        switch (this.multiSelectType) {
                                                            case 'order': {
                                                                this['orderInputStr'] = jerp.strProcessing(this.multiStr);
                                                                this['expressInputStr'] = '';
                                                                break;
                                                            }
                                                            case 'express': {
                                                                this['expressInputStr'] = jerp.strProcessing(this.multiStr);
                                                                this['orderInputStr'] = '';
                                                                break;
                                                            }
                                                        }
                                                        this.orderListsShow(false);
                                                    },
                                                    // 查询缺货异常
                                                    check_outStockOrder: function (orders = [], pageNo = 1) {
                                                        if (pageNo == 1) { jerp.pxmu.showload(); this.copyAvailable = false; }
                                                        this.orderInputStr = '';
                                                        this.expressInputStr = '';
                                                        this.list = [];

                                                        let self = this;
                                                        $.ajax({
                                                            url: location.origin + '/trade/search',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            async: false,
                                                            data: {
                                                                api_name: 'trade_search',
                                                                onlyContain: 4,
                                                                exceptionStatus: 'EXCEP_STOCK_INSUFFICIENT',
                                                                exceptIds: '',
                                                                excludeExceptionStatus: '',
                                                                excludeExceptIds: '',
                                                                tickExcep: 0,
                                                                sysStatus: '',
                                                                _t: Math.round(new Date()),
                                                                pageNo: pageNo,
                                                                queryId: 23,
                                                                order: 'desc',
                                                                pageSize: 50,
                                                                field: 'pay_time',
                                                                needOrder: 0,
                                                                useCompress: 1,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0
                                                            },
                                                            success: function (e) {
                                                                //成功触发
                                                                if (e && e.clueId) {
                                                                    orders = [...orders, ...e.data.list];
                                                                    if (orders.length < e.data.total) {
                                                                        self.check_outStockOrder(orders, pageNo + 1);
                                                                    } else {
                                                                        self.func(orders);
                                                                    }
                                                                }
                                                            },
                                                            error: function (error) {
                                                                //失败，触发
                                                                console.log("error", error);
                                                            }
                                                        })
                                                    },
                                                    check: function () {
                                                        // 4889822473444224,4889818561126402
                                                        if (this.orderInputStr == '' && this.expressInputStr == '') {
                                                            jerp.pxmu.toast('请先输入查询的数据...');
                                                            return;
                                                        }
                                                        this.init();

                                                        let self = this,
                                                            orderWithBG = this.getOrderWithBlankBag(),
                                                            blankBag = {};

                                                        if (orderWithBG.length > 0) {
                                                            for (let i = 0; i < orderWithBG.length; i++) {
                                                                blankBag[orderWithBG[i].b] = true;
                                                            }
                                                        }
                                                        let orderWithoutBG = this.getOrderWithoutBlankBag();
                                                        let orders = [...orderWithBG, ...orderWithoutBG];

                                                        if (orders.length > 0) {

                                                            new Promise(resolve => { // 获取订单详情
                                                                jerp.pxmu.showload();
                                                                let sids = [];
                                                                for (let i = 0; i < orders.length; i++) {
                                                                    sids.push(orders[i].b);
                                                                    // if (sids.length > 3) break;
                                                                }

                                                                // 获取订单详情（商品）
                                                                $.ajax({
                                                                    url: location.origin + '/trade/search/sids',
                                                                    method: 'post',
                                                                    dataType: 'json',
                                                                    data: {
                                                                        'api_name': 'trade_search_sids',
                                                                        order: 'desc',
                                                                        'sids': sids.toString(),
                                                                        withStock: true,
                                                                        field: 'pay_time',
                                                                        minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                    },
                                                                    success: function (e) {
                                                                        resolve(e.data.list);
                                                                    },
                                                                    error: function (e) {
                                                                        jerp.pxmu.fail('订单获取失败，请联系管理员...');
                                                                    }
                                                                })
                                                            }).then(async data => { // 填充订单，并获取商品
                                                                let goodsList = {};
                                                                let isProcessed = 0;
                                                                for (let i = 0; i < data.length; i++) {
                                                                    let h = data[i];
                                                                    let isBG = blankBag[h.sid] ? true : false;
                                                                    let ld = [];
                                                                    let outStockNum = 0;
                                                                    if (h.orders.length > 0) {
                                                                        for (let j = 0; j < h.orders.length; j++) {
                                                                            let d = h.orders[j];
                                                                            if (d.outerId) {
                                                                                let isSuits = d.suits ? true : false;
                                                                                if (!goodsList[d.outerId]) {
                                                                                    goodsList[d.outerId] = {
                                                                                        'outerId': d.outerId,
                                                                                        'title': d.title,
                                                                                        'isSuits': isSuits
                                                                                    };

                                                                                    await jerp.sleep(jerp.delay());

                                                                                    let purchase = await jerp.getLastPurchaseOrder(goodsList[d.outerId]);
                                                                                    // console.log(d.outerId, ': ', purchase);
                                                                                    // if (purchase) {
                                                                                    goodsList[d.outerId] = {
                                                                                        ...goodsList[d.outerId], ...{
                                                                                            id: !purchase ? '' : purchase.id,
                                                                                            code: !purchase ? '' : purchase.code,
                                                                                            deliveryDate: !purchase ? '' : purchase.deliveryDate,
                                                                                            supplierId: !purchase ? '' : purchase.supplierId,
                                                                                            supplierName: !purchase ? '' : purchase.supplierName,
                                                                                            purchasePrice: !purchase ? '' : purchase.purchasePrice,
                                                                                        }
                                                                                    }
                                                                                    // }
                                                                                    let g = await jerp.getGoodsStock({
                                                                                        outerId: d.outerId,
                                                                                        isSuits: isSuits
                                                                                    });
                                                                                    if (g) {
                                                                                        goodsList[d.outerId].mainStockNum = g.mainStockNum ? g.mainStockNum : 0;
                                                                                        goodsList[d.outerId].stockTotal = g.stockTotal ? g.stockTotal : 0;
                                                                                    }
                                                                                }

                                                                                // stockNum: 当前订单锁定的商品数量
                                                                                // num: 订单需求的数量
                                                                                // JT3081751967628
                                                                                let outNum = d.num - d.stockNum;
                                                                                // 需要单独确认一下库存
                                                                                let stockTotal = goodsList[d.outerId].stockTotal;
                                                                                if (isBG) {
                                                                                    if (d.num > stockTotal) {
                                                                                        if (stockTotal > 0) {
                                                                                            outNum = d.num - stockTotal;
                                                                                        } else {
                                                                                            outNum = d.num;
                                                                                        }
                                                                                    }
                                                                                    else {
                                                                                        outNum = 0;
                                                                                    }
                                                                                }
                                                                                if (outNum > 0) {
                                                                                    if (stockTotal > outNum) {
                                                                                        outNum = 0;
                                                                                    }
                                                                                    outStockNum++;
                                                                                }

                                                                                ld.push({
                                                                                    outerId: d.outerId, // 商家编码
                                                                                    title: d.title, // 商品名称
                                                                                    price: d.price, // 单价
                                                                                    payment: d.payment, // 平台实付
                                                                                    pay: d.payment / d.num, // 平台单价
                                                                                    cost: d.cost, // 系统成本
                                                                                    num: d.num, // 订单数量
                                                                                    outNum: outNum,
                                                                                    purchaseNo: goodsList[d.outerId].code,
                                                                                    supplierName: goodsList[d.outerId].supplierName,
                                                                                    purchasePrice: goodsList[d.outerId].purchasePrice,
                                                                                    inStock: outNum == 0,
                                                                                    isSuits: isSuits,
                                                                                });
                                                                            }
                                                                        }
                                                                    }
                                                                    if (ld.length > 0) {
                                                                        self.list.push({
                                                                            isBG: isBG,
                                                                            sid: h.b, // 系统订单号
                                                                            tids: h.gd.toString(), // 平台订单号
                                                                            shortId: h.ge, // 内部短号
                                                                            printTime: h.bo ? jerp.getFormatDate(new Date(h.bo)) : "", // 打印日期
                                                                            sysStatus: h.cl ? jerp.sysStatus[h.cl] : "", // 系统状态
                                                                            status: h.e ? jerp.sysStatus[h.e] : "", // 平台状态
                                                                            outSid: h.y ? h.y : "", // 物流单号
                                                                            inStock: ld.filter(e => !e.inStock).length == 0, // 库存是否充足
                                                                            subShow: false,
                                                                            child: ld
                                                                        });
                                                                    }
                                                                    self.updateTitle(++isProcessed, data.length);
                                                                }
                                                            })
                                                        } else {
                                                            jerp.pxmu.toast('未找到相关数据...');
                                                            this.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    // 查找空包订单
                                                    getOrderWithBlankBag: function (orders = [], pageNo = 1) {
                                                        let self = this;
                                                        let timeStamp = Math.round(new Date());
                                                        let pageSize = 200;
                                                        $.ajax({
                                                            url: location.origin + '/trade/search',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            async: false,
                                                            data: {
                                                                api_name: 'trade_search',
                                                                useHasNext: 1,
                                                                pageNo: pageNo,
                                                                pageSize: pageSize,
                                                                sid: this.orderInputStr,
                                                                timeType: 'pay_time',
                                                                dateTypeSelect: 0,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                outSid: this.expressInputStr,
                                                                key: 'itemTitle',
                                                                btasType: '待质检',
                                                                _t: timeStamp,
                                                                queryType: 1,
                                                                highlight: false,
                                                                field: 'pay_time',
                                                                order: 'desc',
                                                                queryId: 62,
                                                                tradeType: 10,
                                                                // excludeTradeType: 10,
                                                                timeStamp: timeStamp,
                                                                needOrder: 0,
                                                                useCompress: 1
                                                            },
                                                            success: function (e) {
                                                                if (e && e.clueId) {
                                                                    if (e.data.list) {
                                                                        orders = [...orders, ...e.data.list];
                                                                        if (e.data.list.length == pageSize) {
                                                                            orders = self.getOrderWithBlankBag(orders, pageNo + 1);
                                                                        }
                                                                    }
                                                                } else {

                                                                }
                                                            },
                                                            error: function (error) {
                                                                console.log("error", error);
                                                            }
                                                        });

                                                        return orders;
                                                    },
                                                    // 查找非空包订单
                                                    getOrderWithoutBlankBag: function (orders = [], pageNo = 1) {
                                                        let self = this;
                                                        let timeStamp = Math.round(new Date());
                                                        let pageSize = 200;
                                                        $.ajax({
                                                            url: location.origin + '/trade/search',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            async: false,
                                                            data: {
                                                                api_name: 'trade_search',
                                                                useHasNext: 1,
                                                                pageNo: pageNo,
                                                                pageSize: pageSize,
                                                                sid: this.orderInputStr,
                                                                timeType: 'pay_time',
                                                                dateTypeSelect: 0,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                outSid: this.expressInputStr,
                                                                key: 'itemTitle',
                                                                btasType: '待质检',
                                                                _t: timeStamp,
                                                                queryType: 1,
                                                                highlight: false,
                                                                field: 'pay_time',
                                                                order: 'desc',
                                                                queryId: 62,
                                                                // tradeType: 10,
                                                                excludeTradeType: 10,
                                                                timeStamp: timeStamp,
                                                                needOrder: 0,
                                                                useCompress: 1
                                                            },
                                                            success: function (e) {
                                                                if (e && e.clueId) {
                                                                    if (e.data.list) {
                                                                        orders = [...orders, ...e.data.list];
                                                                        if (e.data.list.length == pageSize) {
                                                                            orders = self.getOrderWithoutBlankBag(orders, pageNo + 1);
                                                                        }
                                                                    }
                                                                }
                                                            },
                                                            error: function (error) {
                                                                console.log("error", error);
                                                            }
                                                        });

                                                        return orders;
                                                    },
                                                    subContentShow: function (item) {
                                                        item.subShow = !item.subShow;
                                                    },
                                                    copy2Excel: function (isAll = false) {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }
                                                        let nowTime = jerp.getFormatDate(new Date());
                                                        let copyList = {
                                                            printTime: '打印日期',
                                                            shortId: '内部短号',
                                                            sysStatus: '系统状态',
                                                            outSid: '物流单号',
                                                        }
                                                        let copyListSub = {
                                                            outerId: '商家编码',
                                                            title: '商品名称',
                                                            num: '订单数量',
                                                            outNum: '缺货数量',
                                                            purchaseNo: '采购单号',
                                                            supplierName: '供应商',
                                                        }
                                                        // 先创建标题
                                                        let content = '日期\t';
                                                        for (let i in copyList) {
                                                            content += copyList[i] + '\t,';
                                                        }
                                                        for (let i in copyListSub) {
                                                            content += copyListSub[i] + '\t,';
                                                        }
                                                        content += '\n';
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let l = this.list[i];
                                                            if (!l.inStock || isAll) {
                                                                content += nowTime + '\t,';
                                                                for (let a in copyList) {
                                                                    content += l[a] + '\t,';
                                                                }
                                                                let ldNum = 0;
                                                                for (let j = 0; j < l.child.length; j++) {
                                                                    let d = l.child[j];
                                                                    if (!d.inStock || isAll) {
                                                                        if (ldNum > 0) {
                                                                            content += '\n';
                                                                            content += '\t,'; // nowTime
                                                                            for (let a in copyList) {
                                                                                content += '\t,';
                                                                            }
                                                                        }
                                                                        for (let b in copyListSub) {
                                                                            content += d[b] + '\t,';
                                                                        }
                                                                        ldNum++;
                                                                    }
                                                                }
                                                                content += '\n';
                                                            }
                                                        }
                                                        // jerp.copy(content);

                                                        jerp.downloadCSV(content, isAll ? '报货：全部订单' : '报货：缺货订单');
                                                    }
                                                }
                                            })
                                        }
                                    },
                                    { // 新增商品
                                        name: '新增商品',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特', '云淡风轻', '文员', "文员2"],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner" style="background: #ebebeb;">
                                                        <div class="btnSubmit" style="top: 1rem; right: 5rem;">
                                                            <button class="btn copy" @click="submit()" style="width: 10rem; height: 5rem; font-size: 2rem;">提交</button>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol">
                                                                <span>仓库：</span>
                                                                <select style="width: 8rem;" v-model="warehouse">
                                                                    <option value="" disabled="true" selected="true">请选择仓库</option>
                                                                    <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="">
                                                                <span>商品名称：</span>
                                                                <input type="text" style="width: 15rem;" v-model="data.title" @input="orderNameChange"/>
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="">
                                                                <span>商品编码：</span>
                                                                <input type="text" style="width: 15rem;" v-model="data.outerId" />
                                                            </div>
                                                            <div class="jerpCol" style="">
                                                                <span>商品简称：</span>
                                                                <input type="text" style="width: 15rem;" v-model="data.shortTitle" />
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="align-items: baseline;">
                                                                <span>商品货位：</span>
                                                                <div style="display: flex; flex-flow: column;">
                                                                    <select style="width: 5rem;" v-model="stockSelect" @change="stockChange('select')">
                                                                        <option v-for="item in stocklist" :value="item.value">{{item.name}}</option>
                                                                    </select>
                                                                    <textarea v-show="stockSelect==0" style="width: 34rem; height: 5rem;" v-model="goodsStock" @change="stockChange('input')"
                                                                    placeholder="默认：Z-Z-Z-Z-Z; 丝扣件：Z-S; 卫生件：Z-W; 阀门件：Z-F; 冲压件：Z-C;">
                                                                    </textarea>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="align-items: baseline;">
                                                                <span>商品备注：</span>
                                                                <textarea style="width: 34rem; height: 5rem;" v-model="data.remark">
                                                                </textarea>
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="">
                                                                <span>自定义1（负责人）：</span>
                                                                <input type="text" v-model="data.definedJson[0].definedValue" />
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="">
                                                                <span>自定义2（材　质）：</span>
                                                                <input type="text" v-model="data.definedJson[1].definedValue" />
                                                            </div>
                                                            <div class="jerpCol" style="">
                                                                <span>自定义3（名称）：</span>
                                                                <input type="text" style="width: 15rem;" v-model="data.definedJson[2].definedValue" />
                                                            </div>
                                                            <div class="jerpCol" style="">
                                                                <span>自定义4（规格）：</span>
                                                                <input type="text"  style="width: 15rem;"v-model="data.definedJson[3].definedValue" />
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    // nowTime: null,
                                                    "warehouse": "",
                                                    "warehouseList": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses,
                                                    data: {
                                                        title: "",
                                                        outerId: "",
                                                        shortTitle: "",
                                                        remark: "Z-丝扣类",
                                                        definedJson: [ // 自定义
                                                            {
                                                                "definedKey": "",
                                                                "definedValue": "."
                                                            },
                                                            {
                                                                "definedKey": "",
                                                                "definedValue": ""
                                                            },
                                                            {
                                                                "definedKey": "",
                                                                "definedValue": ""
                                                            },
                                                            {
                                                                "definedKey": "",
                                                                "definedValue": ""
                                                            }
                                                        ]
                                                    },
                                                    stocklist: [{
                                                        name: 'Z-丝扣类',
                                                        value: 'Z-S',
                                                    }, {
                                                        name: 'Z-卫生类',
                                                        value: 'Z-W',
                                                    }, {
                                                        name: 'Z-阀门类',
                                                        value: 'Z-F',
                                                    }, {
                                                        name: 'Z-冲压类',
                                                        value: 'Z-C',
                                                    }, {
                                                        name: '其他',
                                                        value: '0',
                                                    }],
                                                    stockSelect: "Z-S",
                                                    goodsStock: "",
                                                },
                                                mounted: function () {
                                                    this.warehouse = this.warehouseList[0].id;
                                                },
                                                computed: {},
                                                methods: {
                                                    init: function () {
                                                        this.data = {
                                                            title: "",
                                                            outerId: "",
                                                            shortTitle: "",
                                                            remark: "",
                                                            definedJson: [
                                                                {
                                                                    "definedKey": "",
                                                                    "definedValue": "."
                                                                },
                                                                {
                                                                    "definedKey": "",
                                                                    "definedValue": ""
                                                                },
                                                                {
                                                                    "definedKey": "",
                                                                    "definedValue": ""
                                                                },
                                                                {
                                                                    "definedKey": "",
                                                                    "definedValue": ""
                                                                }
                                                            ]
                                                        };
                                                        this.stockChange();
                                                        // this.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                    },
                                                    stockChange: function (type) {
                                                        let self = this;
                                                        switch (type) {
                                                            case 'select': {
                                                                let stock = self.stockSelect;
                                                                if (stock == 0) {
                                                                    self.goodsStock = 'Z-Z-Z-Z-Z';
                                                                    self.data.remark = 'Z-Z-Z-Z-Z';
                                                                } else {
                                                                    self.data.remark = self.stocklist.filter(v => { return v.value == stock })[0].name;
                                                                }
                                                                break;
                                                            }
                                                            case 'input': {
                                                                let stock = self.goodsStock;
                                                                self.data.remark = jerp.setCodeName(stock);
                                                                break;
                                                            }
                                                            default: {
                                                                if (self.stockSelect != 0) {
                                                                    self.stockChange('select');
                                                                } else {
                                                                    self.stockChange('input');
                                                                }
                                                                break;
                                                            }
                                                        }
                                                    },
                                                    updateTitle: function (isProcessed, total) {
                                                        jerp.winSubtitle = `( <span style="color:green;">${this.list.filter(e => !e.inStock).length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        if (isProcessed == total) {
                                                            jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    orderNameChange: function () {
                                                        let title = this.data.title, list = title.split(' '), guige = '';
                                                        this.data.outerId = jerp.title2outerId(title);
                                                        if (list.length == 2) {
                                                            this.data.shortTitle = list[0];
                                                            this.data.definedJson[1].definedValue = ".";
                                                            this.data.definedJson[2].definedValue = list[0];
                                                            this.data.definedJson[3].definedValue = list[1] ? list[1] : "";
                                                        } else {
                                                            if (list.length > 2) {
                                                                list.map((v, i) => {
                                                                    if (i >= 2) {
                                                                        guige += v;
                                                                    }
                                                                })
                                                            }
                                                            this.data.shortTitle = list.length > 1 ? list[0] + ' ' + list[1] : list[0];
                                                            this.data.definedJson[1].definedValue = list[0];
                                                            this.data.definedJson[2].definedValue = list.length > 1 ? list[1] : '';
                                                            this.data.definedJson[3].definedValue = guige;
                                                        }
                                                    },
                                                    submit: async function () {
                                                        // this.init();
                                                        let goodsSectionId = ''; // 1747679, // Z-Z-Z-Z-Z
                                                        // console.log(this.stockSelect);
                                                        // return;
                                                        let sectionLists = await jerp.getData({
                                                            url: '/wms/goodsSection/list',
                                                            method: 'get',
                                                            return: 'data.list',
                                                        }, {
                                                            pageSize: 50,
                                                            pageNo: 1,
                                                            warehouseId: this.warehouse,
                                                            code: this.stockSelect != "0" ? this.stockSelect : this.goodsStock,
                                                            async: false,
                                                            api_name: 'wms_goodsSection_list',
                                                        });
                                                        if (sectionLists.length > 0) {
                                                            goodsSectionId = sectionLists[0].id;
                                                        }
                                                        // console.log("data: ", this.data);
                                                        // console.log("goodsSectionId: ", goodsSectionId);
                                                        // return;
                                                        let newGoods = await jerp.getData({
                                                            url: '/item/add',
                                                            return: 'data',
                                                        }, {
                                                            ...this.data, ...{
                                                                "type": "0",
                                                                "typeTag": "0",
                                                                "catName": "",
                                                                "sellerCids": "-1",
                                                                "barcode": "",
                                                                "isVirtual": "0",
                                                                "shipper": "",
                                                                "brand": "",
                                                                "brandId": "",
                                                                "weight": 0,
                                                                "purchasePrice": "",
                                                                "sellingPrice": 0,
                                                                "makeGift": false,
                                                                "unit": "",
                                                                "wholesalePrice": 0,
                                                                "periodCast": "",
                                                                "place": "",
                                                                "component": "",
                                                                "standard": "",
                                                                "record": "",
                                                                "safekind": "",
                                                                "invoice": "",
                                                                "boxnum": 0,
                                                                "x": "",
                                                                "y": "",
                                                                "z": "",
                                                                "volume": "",
                                                                "bigPic": "",
                                                                "picPath": "",
                                                                "isSysWeight": 0,
                                                                "isSysPriceImport": 0,
                                                                "isSysPriceOutput": 0,
                                                                "isSysWholesalePrice": 0,
                                                                "isSysVolume": 1,
                                                                "isSysOtherPrice1": 1,
                                                                "isSysOtherPrice2": 1,
                                                                "isSysOtherPrice3": 1,
                                                                "isSysOtherPrice4": 1,
                                                                "isSysOtherPrice5": 1,
                                                                "washLabelJson": "",
                                                                "itemSuiteBridgeList": [],
                                                                "declareAmount": "",
                                                                "declareNameEn": "",
                                                                "declareNameZh": "",
                                                                "declareWeight": "",
                                                                "hsCode": "",
                                                                "assistUnitList": [],
                                                                "washLabeltemplateId": "",
                                                                "skulist": [],
                                                                "extendFieldValues": "{\"marketPrice\":\"\",\"otherPrice1\":\"\",\"otherPrice2\":\"\",\"otherPrice3\":\"\",\"otherPrice4\":\"\",\"otherPrice5\":\"\"}",
                                                                "api_name": "item_add",
                                                            }
                                                        }, true)
                                                        // console.log(newGoods);
                                                        if (goodsSectionId != '' && newGoods.id !== undefined && newGoods.id !== null) {
                                                            await jerp.getData({
                                                                url: '/wms/goodsSectionInventory/bindGs',
                                                            }, {
                                                                "goodsSectionId": goodsSectionId,
                                                                "itemIds": newGoods.id + '_0',
                                                                "api_name": 'wms_goodsSectionInventory_bindGs',
                                                            })

                                                            jerp.pxmu.toast('完成');

                                                            this.init();
                                                        } else {
                                                            jerp.pxmu.toast(newGoods.message); // 检查，账号掉线后的返回
                                                        }
                                                    },
                                                }
                                            })
                                        }
                                    }
                                ]
                            },
                            { // 交易
                                name: '交易',
                                subName: '',
                                active: false,
                                status: false,
                                role: [],
                                child: [
                                    { // 检查：库存不足
                                        name: '检查：库存不足',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <input v-model="orderInputStr" placeholder="输入系统单号"></input>
                                                            <i class="btnInner" @click="orderListsShow(true)">+</i>
                                                        </div> 
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                            <button class="btn btn_blue" @click="cancelException()">取消异常</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <span>复制：</span>
                                                        <button class="btn copy" @click="copyInStock()">库存充足订单</button>
                                                        <button class="btn copy" @click="copyInStock2Excel()">结果导出至excel</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 3;"><span>系统单号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>内部短号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>订单状态</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>库存充足</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row" @click="subContentShow(item)">
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>{{item.code}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.shortId}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.sysStatus}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{inStockStr(item.inStock)}}</span></div>
                                                                        </div>
                                                                        <div class="jTable_sub" v-show="item.subShow">
                                                                            <div class="jTable_subTitle">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex:3"><span>商品名称</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>订单数量</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>缺货数量</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>拣货区库存</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>总库存</span></div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_subContent">
                                                                                <div class="jTable_row" v-for="(subItem,subIndex) in item.child">
                                                                                    <div class="jTable_col" style="flex:3"><span>{{subItem.title}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.num}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.outNum}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.mainStockNum}}</span></div>
                                                                                    <div class="jTable_col" style="flex:1"><span>{{subItem.stockTotal}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="multiInputShow">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>批量添加</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="orderListsShow(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner">
                                                    <div class="inputCol">
                                                        <textarea v-model="textareaStr"></textarea>
                                                    </div>
                                                </div>
                                                <div class="selectFooter">
                                                    <a class="btn" @click="confirm()">确定</a>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    copyAvailable: true,
                                                    orderInputStr: '',
                                                    multiInputShow: false,
                                                    textareaStr: '',
                                                    list: [],
                                                    nowTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                                                },
                                                computed: {
                                                    inStockStr: function () {
                                                        return (status) => {
                                                            return status ? '是' : '';
                                                        }
                                                    }
                                                },
                                                methods: {
                                                    updateTitle: function (isProcessed, total) {
                                                        jerp.winSubtitle = `( <span style="color:green;">${this.list.filter(e => e.inStock && e.isShow).length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        if (isProcessed == total) {
                                                            jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    orderListsShow: function (status) {
                                                        this.multiInputShow = status;
                                                    },
                                                    confirm: function () {
                                                        // console.log(this.textareaStr);
                                                        this.orderInputStr = jerp.strProcessing(this.textareaStr);
                                                        // console.log(this.orderInputStr);
                                                        this.orderListsShow(false);
                                                    },
                                                    subContentShow: function (item) {
                                                        item.subShow = !item.subShow;
                                                    },
                                                    check: function () {
                                                        let self = this;
                                                        jerp.pxmu.showload();
                                                        this.copyAvailable = false;
                                                        jerp.getOrders({ // 不要带pageNo,pageSize
                                                            api_name: 'trade_search',
                                                            queryId: 23,
                                                            order: 'desc',
                                                            _t: Math.round(new Date()),
                                                            onlyContain: 4,
                                                            exceptionStatus: 'EXCEP_STOCK_INSUFFICIENT',
                                                            tickExcep: 0,
                                                            sid: this.orderInputStr,
                                                            timeType: 'pay_time',
                                                            dateTypeSelect: 0,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            key: 'mainOuterId',
                                                            btasType: '待质检',
                                                            queryType: 1,
                                                            highlight: false,
                                                            field: 'pay_time',
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                        }, 200).then(orders => {
                                                            if (orders.length > 0) {
                                                                let goodsList = {};
                                                                let isProcessed = 0;
                                                                new Promise(resolve => { // 获取订单
                                                                    let sids = [];
                                                                    for (let i = 0; i < orders.length; i++) {
                                                                        sids.push(orders[i].b);
                                                                        // if (sids.length > 3) break;
                                                                    }
                                                                    $.ajax({
                                                                        url: location.origin + '/trade/search/sids',
                                                                        method: 'post',
                                                                        dataType: 'json',
                                                                        data: {
                                                                            'api_name': 'trade_search_sids',
                                                                            order: 'desc',
                                                                            'sids': sids.toString(),
                                                                            withStock: true,
                                                                            field: 'pay_time',
                                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                        },
                                                                        success: function (e) {
                                                                            if (e && e.clueId && e.result == 1) {
                                                                                resolve(e.data.list);
                                                                            } else {
                                                                                this.copyAvailable = true;
                                                                                jerp.pxmu.closeload(e.message);
                                                                                console.log(e.message);
                                                                                reject();
                                                                            }
                                                                        },
                                                                        error: function (e) {
                                                                            self.updateTitle(++isProcessed, orders.length);
                                                                            console.log(e.message);
                                                                            reject();
                                                                        }
                                                                    })
                                                                }).then(async data => { // 获取
                                                                    if (data.length > 0) {
                                                                        for (let i = 0; i < data.length; i++) {
                                                                            let h = data[i];
                                                                            let ld = [];
                                                                            // let inStock = true;
                                                                            for (let j = 0; j < h.orders.length; j++) {
                                                                                let d = h.orders[j];
                                                                                if (!d.outerId) continue;
                                                                                let isSuits = d.suits ? true : false; // 是否是套件
                                                                                // 找到缺货的商品
                                                                                // stockNum: 订单锁定的商品数量
                                                                                // num: 订单数量
                                                                                let outNum = d.num - d.stockNum;
                                                                                if (outNum > 0) {
                                                                                    if (!goodsList[d.outerId]) {
                                                                                        goodsList[d.outerId] = {
                                                                                            'outerId': d.outerId,
                                                                                            'title': d.title,
                                                                                            'isSuits': isSuits
                                                                                        };

                                                                                        await jerp.sleep();

                                                                                        let g = await jerp.getGoodsStock({
                                                                                            outerId: d.outerId,
                                                                                            isSuits: isSuits
                                                                                        })
                                                                                        goodsList[d.outerId].mainStockNum = g.mainStockNum ? g.mainStockNum : 0;
                                                                                        goodsList[d.outerId].stockTotal = g.stockTotal ? g.stockTotal : 0;
                                                                                    }
                                                                                }
                                                                                let mainStockNum = '', stockTotal = '', inStock = true;
                                                                                if (goodsList[d.outerId]) {
                                                                                    mainStockNum = goodsList[d.outerId].mainStockNum;
                                                                                    stockTotal = goodsList[d.outerId].stockTotal;
                                                                                    inStock = stockTotal >= outNum;
                                                                                }

                                                                                ld.push({
                                                                                    outerId: d.outerId,
                                                                                    title: d.title,
                                                                                    num: d.num,
                                                                                    outNum: outNum,
                                                                                    mainStockNum: mainStockNum,
                                                                                    stockTotal: stockTotal,
                                                                                    inStock: inStock,
                                                                                    isSuits: d.suits ? true : false,
                                                                                });
                                                                            }
                                                                            self.list.push({
                                                                                code: h.sid,
                                                                                shortId: h.shortId,
                                                                                sysStatus: jerp.sysStatus[h.sysStatus],
                                                                                subShow: false,
                                                                                inStock: ld.filter(e => !e.inStock).length == 0,
                                                                                child: ld,
                                                                            });
                                                                            self.updateTitle(++isProcessed, data.length);
                                                                        }
                                                                        // resolve();
                                                                    } else {
                                                                        this.copyAvailable = true;
                                                                        jerp.pxmu.closeload('错误，请联系管理员！');
                                                                    }
                                                                }).catch(() => {
                                                                    this.copyAvailable = true;
                                                                    jerp.pxmu.closeload('错误，请联系管理员！');
                                                                })
                                                            } else {
                                                                this.copyAvailable = true;
                                                                jerp.pxmu.closeload('未找到相关数据...');
                                                            }
                                                        });
                                                    },
                                                    copyInStock: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let content = '';
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let h = this.list[i];
                                                            if (h.inStock) {
                                                                content += h.code + '\n';
                                                            }
                                                        }
                                                        if (content == '') {
                                                            jerp.pxmu.toast('没有库存充足的异常订单...');
                                                            return;
                                                        }
                                                        jerp.copy(content);
                                                    },
                                                    copyInStock2Excel: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let content = '';
                                                        let copyList = {
                                                            code: '系统单号',
                                                            shortId: '内部短号',
                                                            sysStatus: '系统状态',
                                                            inStock: '库存充足',
                                                        }
                                                        let copyListSub = {
                                                            outerId: '商家编码',
                                                            title: '商品名称',
                                                            num: '订单数量',
                                                            outNum: '缺货数量',
                                                            mainStockNum: '拣货区库存',
                                                            stockTotal: '总库存',
                                                        }
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            content += copyList[i] + '\t';
                                                        }
                                                        for (let i in copyListSub) {
                                                            content += copyListSub[i] + '\t';
                                                        }
                                                        content += '\n';
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let l = this.list[i];
                                                            for (let a in copyList) {
                                                                content += l[a] + '\t';
                                                            }
                                                            for (let j = 0, ldNum = 0; j < l.child.length; j++) {
                                                                let d = l.child[j];
                                                                if (ldNum > 0) {
                                                                    content += '\n';
                                                                    for (let a in copyList) {
                                                                        content += '\t';
                                                                    }
                                                                }
                                                                for (let b in copyListSub) {
                                                                    content += d[b] + '\t';
                                                                }
                                                                ldNum++;
                                                            }
                                                            content += '\n';
                                                        }
                                                        jerp.copy(content);
                                                    },
                                                    cancelException: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let isList = this.list.filter(v => v.inStock);
                                                        let sids = isList.map(v => v.code);
                                                        // console.log(sids);
                                                        $.ajax({
                                                            url: location.origin + '/trade/insufficient/cancel',
                                                            method: 'post',
                                                            dataType: 'json',
                                                            // async: true,
                                                            data: {
                                                                api_name: 'trade_insufficient_cancel',
                                                                sids: sids.toString()
                                                            },
                                                            success: function (e) {
                                                                if (e.result == 1) {
                                                                    jerp.pxmu.toast('取消异常完毕');
                                                                } else {
                                                                    jerp.pxmu.toast('取消异常错误，请联系管理员');
                                                                }
                                                            },
                                                            error: function (e) { }
                                                        });
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 订单查询
                                        name: '订单查询',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特', '叶小珍', '王梦璇', '云淡风轻'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="display:flex;flex-flow:column;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" @mouseleave="closeStoreSelect">
                                                            <span>店铺：</span>
                                                            <input v-model="shopsStr" style="cursor:pointer;" @click="openStoreSelect"></input>
                                                            <i class="btnInner" @click="openStoreSelect">+</i>
                                                            <div v-show="storeSelectStatus"
                                                            style="position: absolute;top: 1.3rem;right: 0;background: white;width: calc(100% - 1rem);
                                                            z-index: 10000;margin: 0.15rem;padding: 0.5rem;border: 1px solid #d8d8d8;">
                                                                <div class="jerpRow" v-for="item in bindShops" @click="choiceStore(item)"
                                                                    style="cursor: pointer;border-bottom: 1px solid #ebebeb;"
                                                                    :style="item.status?{'background': '#f79595','color': 'white;'}:''">
                                                                    <div class="jerpCol">
                                                                        <span :class="'shopFlag-'+item.source">{{item.flag}}</span>
                                                                    </div>
                                                                    <div class="jerpCol">
                                                                        {{item.title}}
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <span>主仓：</span>
                                                            <select style="width: 8rem;" v-model="warehouse">
                                                                <option value="" disabled="true" selected="true">请选择仓库</option>
                                                                <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <span>备用仓：</span>
                                                            <select style="width: 8rem;" v-model="warehouse2">
                                                                <option value="" selected="true">未选择</option>
                                                                <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>日期：</span>
                                                            <input type="datetime-local" max="timeEnd" v-model="timeStart"></input>
                                                            <span>-</span>
                                                            <input type="datetime-local" min="timeStart" v-model="timeEnd"></input>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <select v-model="multiSelect.checkType">
                                                                <option value="sid">系统单号</option>
                                                                <option value="tid">平台单号</option>
                                                                <option value="outSid">快递单号</option>
                                                            </select>
                                                            <!-- 
                                                                <input v-model="multiSelect.orderInputStr" placeholder="输入系统单号" @keyup.enter="check($event)"></input>
                                                                <i class="btnInner" @click="orderListsShow(true, 'order')">+</i>
                                                            -->
                                                        </div>
                                                        <div class="jerpCol">
                                                            <input v-model="multiSelect.checkInputStr" placeholder="输入单号" @keyup.enter="check($event)"></input>
                                                            <i class="btnInner" @click="orderListsShow(true, 'check')">+</i>
                                                            <!-- 
                                                                <input v-model="multiSelect.expressInputStr" placeholder="输入快递单号" @keyup.enter="check($event)"></input>
                                                                <i class="btnInner" @click="orderListsShow(true, 'express')">+</i>
                                                            -->
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                            <input type="checkbox" v-model="getAll">分段获取?</input>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>筛选：</span>
                                                            <div class="jerpCol" style="display:flex;" :style="{'background':item.child!=undefined&&item.type!=0?'#d3d3d3':'','border-radius':item.child!=undefined&&item.type!=0?'0.5rem':''}" v-for="item in filter">
                                                                <button class="btn filterBtn" :style="[item.typeList[item.type].style,{'margin-right':item.child!=undefined&&item.type!=0?'0.2rem':''}]" @click="toggleFilter(item)">
                                                                    {{item.typeList[item.type].title}}
                                                                </button>
                                                                <div class="jerpCol" v-show="item.type!=0" v-for="subitem in item.child">
                                                                    <button class="btn filterBtn" :style="subitem.typeList[subitem.type].style" @click="toggleFilter(subitem)">
                                                                        {{subitem.typeList[subitem.type].title}}
                                                                    </button>
                                                                </div>
                                                            </div>
                                                            <span style="margin-left:0.5rem;color:gray;width: 7rem;">查物流速度比较慢，如无必要<span style="font-weight:bold;color:red;">不要勾选</span></span>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <input type="checkbox" v-model="FillInfo">填充订单信息</input>
                                                        <input type="checkbox" v-model="DLRemark">备注、标签</input>
                                                        <button class="btn copy" @click="export2Excel()">导出</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>系统单号</span></div>
                                                                    <!-- <div class="jTable_col" style="flex: 2;"><span>内部短号</span></div> -->
                                                                    <div class="jTable_col" style="flex: 2;"><span>平台单号</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>系统状态</span></div>
                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.more.child.isJX.type!=0"><span>拣选</span></div>
                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.more.child.isBZ.type!=0"><span>包装</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>店铺</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>快递单号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>打印时间</span></div>
                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.express.type!=0"><span>物流</span></div>
                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.express.child.arrived.type!=0"><span>快递时效</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>下单日期</span></div>
                                                                    <div class="jTable_col" style="flex: 1;" v-show="filter.more.child.isPicked.type!=0"><span>已出库</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content" style="min-height: 25.6rem;">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list_filter">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{((jTable.footer.nowTab-1)*jTable.footer.showTabNum)+index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.sid}}</span></div>
                                                                            <!-- <div class="jTable_col" style="flex: 2;"><span>{{item.shortId}}</span></div> -->
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.tids}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.sysStatus}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;" v-show="filter.more.child.isJX.type!=0"><span>{{item.jx_operator!=""?item.jx_operator+','+item.jx_operateTime:''}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;" v-show="filter.more.child.isBZ.type!=0"><span>{{item.bz_operator!=""?item.bz_operator+','+item.bz_operateTime:''}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.store}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.outSid}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.expressPrintTime}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;" v-show="filter.express.type!=0"><span>{{item.expressDesc}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;" v-show="filter.express.child.arrived.type!=0"><span>{{item.arrived}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.created}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;" v-show="filter.more.child.isPicked.type!=0"><span>{{item.isPicked}}</span></div>
                                                                        </div>
                                                                        <div class="jTable_sub" v-show="filter.goodsDetail.type==1">
                                                                            <div class="jTable_subTitle">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col"><span>序号</span></div>
                                                                                    <div class="jTable_col" style="flex: 4;"><span>商品名称</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;"><span>供应商</span></div>
                                                                                    <div class="jTable_col" style="flex: 1;"><span>数量</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>新仓货位</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>在架数</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>备货货位</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>在架数</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;"><span>状态</span></div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_subContent">
                                                                                <div class="jTable_row" v-for="(subItem,subIndex) in item.child">
                                                                                <div class="jTable_col"><span>{{subIndex + 1}}</span></div>
                                                                                <div class="jTable_col" style="flex: 4;"><span>{{subItem.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;"><span>{{subItem.supplierName}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{subItem.num}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>{{subItem.xcCodes}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>{{subItem.xcTotalNum}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>{{subItem.bhCodes}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;" v-show="filter.goodsDetail.child.goodsStock.type!=0"><span>{{subItem.bhCodes!=""?subItem.bhTotalNum:""}}</span></div>
                                                                                <div class="jTable_col" style="flex: 2;"><span>{{subItem.sysStatus}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_footer">
                                                                <div class="jerpRow">
                                                                    <div class="jerpCol">
                                                                        <div>共{{list.length}}条数据</div>
                                                                    </div>
                                                                </div>
                                                                <div class="jerpRow">
                                                                    <div class="jerpCol" style="margin-right: 1rem;">
                                                                        <div>
                                                                            <span>显示</span>
                                                                            <select v-model="jTable.footer.showTabNum">
                                                                                <option value="0">全部</option>
                                                                                <option value="50">50</option>
                                                                                <option value="100">100</option>
                                                                                <option value="200">200</option>
                                                                                <option value="500">500</option>
                                                                            </select>
                                                                            <span>数据</span>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jerpCol">
                                                                        <div class="jTable_footer_btn">
                                                                            <button :disabled="jTable.footer.nowTab<=1" @click="turnUp"><</button>
                                                                        </div>
                                                                        <div>
                                                                            <span>第</span>
                                                                            <input type="rel" v-model="jTable.footer.nowTabInput" @change="tableTurn"></input>
                                                                            <span>页/共{{jTable.footer.maxTab}}页</span>
                                                                        </div>
                                                                        <div class="jTable_footer_btn">
                                                                            <button :disabled="jTable.footer.nowTab>=jTable.footer.maxTab" @click="turnDown">></button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="multiSelect.multiInputShow">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>批量添加</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="orderListsShow(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner">
                                                    <div class="inputCol">
                                                        <textarea v-model="multiSelect.multiStr"></textarea>
                                                    </div>
                                                </div>
                                                <div class="selectFooter">
                                                    <a class="btn" @click="confirm()">确定</a>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "warehouse": "", // 主仓
                                                    "warehouse2": "", // 备用仓
                                                    "warehouseList": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses,
                                                    "FillInfo": false,
                                                    "DLRemark": false,
                                                    "xc": 10,
                                                    "xcNum": 0,
                                                    "filter": {
                                                        goodsDetail: {
                                                            type: 0,
                                                            typeList: [{
                                                                title: '商品',
                                                                style: {
                                                                    'color': '#b3b2b2',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '商品',
                                                                style: {
                                                                    'background': '#2695fa',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }],
                                                            child: {
                                                                goodsStock: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '库存、货位',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '库存、货位',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                }
                                                            }
                                                        },
                                                        express: {
                                                            type: 0,
                                                            typeList: [{
                                                                title: '物流',
                                                                style: {
                                                                    'color': '#b3b2b2',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '物流',
                                                                style: {
                                                                    'background': '#2695fa',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '有物流',
                                                                style: {
                                                                    'background': 'green',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '无物流',
                                                                style: {
                                                                    'background': 'red',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }],
                                                            child: {
                                                                isNew: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '最新',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '已取件',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                },
                                                                arrived: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '时效',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '时效',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                }
                                                            }
                                                        },
                                                        more: {
                                                            type: 0,
                                                            typeList: [{
                                                                title: '更多',
                                                                style: {
                                                                    'color': '#b3b2b2',
                                                                    'border': 'none'
                                                                }
                                                            }, {
                                                                title: '更多',
                                                                style: {
                                                                    'background': '#2695fa',
                                                                    'color': 'rgb(255 255 255)',
                                                                    'border': 'none'
                                                                }
                                                            }],
                                                            child: {
                                                                isJX: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '拣选',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '拣选',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '已拣选',
                                                                        style: {
                                                                            'background': 'green',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '未拣选',
                                                                        style: {
                                                                            'background': 'red',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                },
                                                                isBZ: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '包装',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '包装',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '已包装',
                                                                        style: {
                                                                            'background': 'green',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '未包装',
                                                                        style: {
                                                                            'background': 'red',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                },
                                                                isPicked: {
                                                                    type: 0,
                                                                    typeList: [{
                                                                        title: '发货',
                                                                        style: {
                                                                            'color': '#b3b2b2',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '发货',
                                                                        style: {
                                                                            'background': '#2695fa',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '已发货',
                                                                        style: {
                                                                            'background': 'green',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }, {
                                                                        title: '未发货',
                                                                        style: {
                                                                            'background': 'red',
                                                                            'color': 'rgb(255 255 255)',
                                                                            'border': 'none'
                                                                        }
                                                                    }]
                                                                }
                                                            }
                                                        }
                                                    },
                                                    'multiSelect': {
                                                        "multiSelectType": '',
                                                        "multiInputShow": false,
                                                        "orderInputStr": '',
                                                        "expressInputStr": '',
                                                        'checkType': 'outSid',
                                                        "checkInputStr": '',
                                                        "multiStr": '',
                                                    },
                                                    "getAll": false,
                                                    "storeSelectStatus": false,
                                                    "bindShops": [],
                                                    "isSelectGoods": false,
                                                    "copyAvailable": false,
                                                    "timeStart": '2024-10-7',
                                                    "timeEnd": '2024-10-7',
                                                    "list": [],
                                                    "list2": [],
                                                    "listObj": {},
                                                    "nowTime": null,
                                                    "jTable": {
                                                        "footer": {
                                                            "showTabNum": 50,
                                                            "showTabList": [],
                                                            "nowTab": 1,
                                                            "nowTabInput": 1,
                                                            "maxTab": 0,
                                                        }
                                                    }
                                                },
                                                mounted: function () {
                                                    this.timeEnd = jerp.getFormatDate(new Date(), 'yyyy-MM-dd 23:59:59');
                                                    let y = new Date().getFullYear(), m = new Date().getMonth() + 1, d = new Date().getDate();
                                                    this.timeStart = jerp.getFormatDate(new Date((m == 1 ? y - 1 : y) + "-" + (m == 1 ? 12 : m - 1) + "-" + d), 'yyyy-MM-dd 00:00:00');

                                                    let list = [], bindShops = jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].bindShops;
                                                    for (let i = 0; i < bindShops.length; i++) {
                                                        let s = JSON.parse(JSON.stringify(bindShops[i]));
                                                        s.status = false;
                                                        list.push(s);
                                                    }
                                                    this.bindShops = list;

                                                    this.warehouse = this.warehouseList[0].id;
                                                    this.warehouse2 = "";
                                                },
                                                computed: {
                                                    shopsStr: function () {
                                                        let isNoStore = false;
                                                        let list = this.bindShops.filter(v => { // .sort((a, b) => a.userId - b.userId)
                                                            if (v.userId < 0 && v.status) {
                                                                isNoStore = true;
                                                            }
                                                            if (isNoStore) {
                                                                v.status = false;
                                                            }
                                                            return v.status
                                                        });
                                                        if (list.length == 0) {
                                                            return "所有店铺";
                                                        } else {
                                                            return '已选择' + list.length + '个店铺';
                                                        }
                                                    },
                                                    isPickedStr: function () {
                                                        return (isPicked) => { return isPicked ? "" : "未出库"; }
                                                    },
                                                    list_filter: function () {
                                                        let self = this, showList = [],
                                                            showTabNum = self.jTable.footer.showTabNum;

                                                        this.jTable.footer.maxTab =
                                                            this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(self.list.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.footer.nowTab > this.jTable.footer.maxTab) {
                                                            this.jTable.footer.nowTab = 1;
                                                            this.jTable.footer.nowTabInput = 1;
                                                        }
                                                        if (showTabNum == 0) {
                                                            return self.list;
                                                        } else {
                                                            for (let i = (this.jTable.footer.nowTab - 1) * showTabNum; i < this.jTable.footer.nowTab * showTabNum; i++) {
                                                                if (i >= self.list.length) break;
                                                                showList.push(self.list[i]);
                                                            }
                                                            return showList;
                                                        }
                                                    },
                                                },
                                                methods: {
                                                    turnUp: function () {
                                                        this.jTable.footer.nowTabInput--;
                                                        this.tableTurn();
                                                    },
                                                    turnDown: function () {
                                                        this.jTable.footer.nowTabInput++;
                                                        this.tableTurn();
                                                    },
                                                    tableTurn: function () {
                                                        // let maxTab = this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(this.list.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.footer.nowTabInput < 1) {
                                                            this.jTable.footer.nowTabInput = 1;
                                                        }
                                                        if (this.jTable.footer.nowTabInput > this.jTable.footer.maxTab) {
                                                            this.jTable.footer.nowTabInput = this.jTable.footer.maxTab;
                                                        }
                                                        this.jTable.footer.nowTab = this.jTable.footer.nowTabInput;
                                                    },
                                                    itemIsShow: function (v, f = false) {
                                                        let self = this, flag = true,
                                                            expressType = self.filter.express.type,
                                                            isPicked = self.filter.more.child.isPicked.type,
                                                            isJX = self.filter.more.child.isJX.type,
                                                            isBZ = self.filter.more.child.isBZ.type;
                                                        if (!f && ((expressType == 2 && (v.expressDesc == '' || v.expressDesc.includes('等待揽收'))) ||
                                                            (expressType == 3 && (v.expressDesc != '' && !v.expressDesc.includes('等待揽收'))))
                                                        ) {
                                                            flag = false;
                                                        }
                                                        if (!f && ((isPicked == 2 && !v.isPicked) ||
                                                            (isPicked == 3 && v.isPicked))) {
                                                            flag = false;
                                                        }
                                                        if (!f && ((isJX == 2 && v.jx_operator == '') ||
                                                            (isJX == 3 && v.jx_operator != ''))) {
                                                            flag = false;
                                                        }
                                                        if (!f && ((isBZ == 2 && v.bz_operator == '') ||
                                                            (isBZ == 3 && v.bz_operator != ''))) {
                                                            flag = false;
                                                        }
                                                        return flag;
                                                    },
                                                    toggleFilter: function (filter) {
                                                        filter.type = filter.type + 1 < filter.typeList.length ? filter.type + 1 : 0;
                                                    },
                                                    openStoreSelect: function () {
                                                        this.storeSelectStatus = true;
                                                    },
                                                    closeStoreSelect: function () {
                                                        this.storeSelectStatus = false;
                                                    },
                                                    choiceStore: function (v) {
                                                        v.status = !v.status;
                                                        // console.log(JSON.parse(JSON.stringify(v)), v.status, !v.status + ' => ' + v.status);
                                                    },
                                                    updateTitle: function (total, filter) {
                                                        let filterStatusStr = "", index = 0;
                                                        for (let i in filter) {
                                                            let h = filter[i], c = h.child;
                                                            filterStatusStr += `${h.typeList[0].title}: ${h.type == 0 ? '否' : '是'}`;
                                                            if (++index < Object.keys(filter).length) {
                                                                filterStatusStr += ', ';
                                                            }
                                                        }
                                                        // jerp.winSubtitle = `( <span style="color:blue;">${isProcessed}</span> / ${total} ) |  ${this.nowTime} | 搜索条件：(  ${filterStatusStr} )`;
                                                        // jerp.winSubtitle = `<span style="color:blue;">${this.list.length}</span> / ${total} | ${this.nowTime} | 搜索条件：( ${filterStatusStr} )`;

                                                        jerp.winTitle.get = this.list.length;
                                                        jerp.winTitle.total = total;
                                                        jerp.winTitle.getTime = this.nowTime;
                                                        jerp.winTitle.otherContent = `| 搜索条件： ${filterStatusStr}`;
                                                    },
                                                    orderListsShow: function (status, type) {
                                                        let multiStrList = [], multiStr = '';
                                                        if (status) {
                                                            this.multiSelect.multiSelectType = type;
                                                            multiStrList = this.multiSelect[type + 'InputStr'].split(',');

                                                            if (multiStrList.length > 0) {
                                                                for (let i = 0; i < multiStrList.length; i++) {
                                                                    if (multiStrList[i] != "") {
                                                                        multiStr += multiStrList[i] + '\n';
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        this.multiSelect.multiStr = multiStr;
                                                        this.multiSelect.multiInputShow = status;
                                                    },
                                                    confirm: function () {
                                                        switch (this.multiSelect.multiSelectType) {
                                                            case 'order': {
                                                                this.multiSelect['orderInputStr'] = jerp.strProcessing(this.multiSelect.multiStr);
                                                                this.multiSelect['expressInputStr'] = '';
                                                                break;
                                                            }
                                                            case 'express': {
                                                                this.multiSelect['expressInputStr'] = jerp.strProcessing(this.multiSelect.multiStr);
                                                                this.multiSelect['orderInputStr'] = '';
                                                                break;
                                                            }
                                                            case 'check': {
                                                                this.multiSelect.checkInputStr = jerp.strProcessing(this.multiSelect.multiStr);
                                                                break;
                                                            }
                                                        }
                                                        this.orderListsShow(false);
                                                    },
                                                    check_old: async function (event) {
                                                        this.jTable.footer.nowTabInput = 1;
                                                        this.jTable.footer.nowTab = 1;

                                                        if (event != undefined) {
                                                            let tar = event.target;
                                                            tar.setSelectionRange(0, tar.value.length);
                                                        }
                                                        // console.log(event);
                                                        // return;
                                                        if (this.timeStart == '' || this.timeEnd == "") { jerp.pxmu.toast('请填写正确的时间!'); return []; }
                                                        if (this.getAll == false &&
                                                            this.orderInputStr == "" && this.expressInputStr == "" &&
                                                            new Date(this.timeEnd).getTime() - new Date(this.timeStart).getTime() > 864000000) {
                                                            // console.log(new Date(this.timeEnd).getTime() - new Date(this.timeStart).getTime());
                                                            jerp.pxmu.toast('查询数据量较大，请勾选分段获取');
                                                            return;
                                                        }
                                                        // return;
                                                        jerp.pxmu.showload('数据加载中...');
                                                        let self = this,
                                                            startTime = new Date(this.timeStart).getTime(),
                                                            endTime = new Date(this.timeEnd).getTime(),
                                                            filter = JSON.parse(JSON.stringify(this.filter));
                                                        self.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                        self.updateTitle(0, filter);
                                                        self.copyAvailable = false;
                                                        self.list = [];
                                                        self.listObj = {};

                                                        // 去除重复项
                                                        let orderInputStr = '', expressInputStr = '', userId = [];
                                                        if (self.multiSelect.orderInputStr != '') {
                                                            let orderList = [], orderObj = {};
                                                            let multiStrList = self.multiSelect.orderInputStr.split(',');
                                                            if (multiStrList.length > 0) {
                                                                for (let i = 0; i < multiStrList.length; i++) {
                                                                    let sid = multiStrList[i];
                                                                    if (!orderObj[sid]) {
                                                                        orderList.push(sid);
                                                                        orderObj[sid] = '已添加';
                                                                    }
                                                                }
                                                                orderInputStr = orderList.toString();
                                                            }
                                                        }
                                                        if (self.multiSelect.expressInputStr != '') {
                                                            let orderList = [], orderObj = {};
                                                            let multiStrList = self.multiSelect.expressInputStr.split(',');
                                                            if (multiStrList.length > 0) {
                                                                for (let i = 0; i < multiStrList.length; i++) {
                                                                    let sid = multiStrList[i];
                                                                    if (!orderObj[sid]) {
                                                                        orderList.push(sid);
                                                                        orderObj[sid] = '已添加';
                                                                    }
                                                                }
                                                                expressInputStr = orderList.toString();
                                                            }
                                                        }
                                                        self.bindShops.map(v => { if (v.status) userId.push(v.userId); });
                                                        let param = { getAll: !self.getAll, orderInputStr, expressInputStr, userId, startTime, endTime, filter, pageNo: 1, pageSize: 1000 };
                                                        if (param.getAll) {
                                                            let newOrders = await self.getNewOrders(param);
                                                            let oldOrders = await self.getOldOrders(param);
                                                            let orders = [...newOrders, ...oldOrders];
                                                            // console.log(orders);
                                                            if (orders.length == 0) { jerp.pxmu.toast('未查询到相关单据...'); jerp.pxmu.closeload(); return; }
                                                            await self.setList(orders, param);
                                                            self.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                        } else {
                                                            param.pageNo = 1;
                                                            while (1) {
                                                                let newOrders = await self.getNewOrders(param);
                                                                await self.setList(newOrders, param);
                                                                if (newOrders.length == 0 || newOrders.length < param.pageSize) {
                                                                    break;
                                                                }
                                                                param.pageNo += 1;
                                                                await jerp.sleep(1000);
                                                            }
                                                            param.pageNo = 1;
                                                            while (1) {
                                                                let oldOrders = await self.getOldOrders(param);
                                                                await self.setList(oldOrders, param);
                                                                if (oldOrders.length == 0 || oldOrders.length < param.pageSize) {
                                                                    break;
                                                                }
                                                                param.pageNo += 1;
                                                                await jerp.sleep(1000);
                                                            }
                                                            self.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    getOldOrders_old: async function (param) {
                                                        let orders = [];
                                                        // 获取三月前的归档订单
                                                        let ordersOld = await jerp.getData({
                                                            // title: '(2/4)获取归档订单……',
                                                            url: '/trade/search3month',
                                                            api_name: 'trade_search3month',
                                                            return: 'data.list',
                                                        }, {
                                                            sid: param.orderInputStr,
                                                            outSid: param.expressInputStr,
                                                            timeType: 'pay_time',
                                                            dateTypeSelect: 0,
                                                            startTime: param.startTime,
                                                            endTime: param.endTime,
                                                            userId: param.userId.toString(),
                                                            highlight: false,
                                                            field: 'pay_time',
                                                            order: 'asc',
                                                            queryId: 9,
                                                            queryOrder: 0,
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            pageNo: param.pageNo,
                                                            pageSize: param.pageSize,
                                                        }, false, param.getAll);
                                                        // console.log('ordersOld: ', ordersOld);
                                                        if (ordersOld && ordersOld.length > 0) {
                                                            for (let i = 0; i < ordersOld.length; i++) {
                                                                let h = ordersOld[i],
                                                                    tagListArr = [];
                                                                if (h.tagList != undefined && h.tagList.length > 0) h.tagList.map(v => tagListArr.push(v.tagName));
                                                                // console.log(h, h && h.sid && !orderNewObj[h.sid]);
                                                                // if (h && h.sid && !orderNewObj[h.sid]) {
                                                                orders.push({
                                                                    sid: h.sid,
                                                                    tids: h.tids.length > 0 ? h.tids.toString() : h.tid,
                                                                    shortId: h.shortId,
                                                                    sysStatus: h.chStatus,
                                                                    outSid: h.outSid,
                                                                    expressPrintTime: h.expressPrintTime,
                                                                    taobaoId: h.taobaoId,
                                                                    scalping: h.scalping ? true : false, // 空单
                                                                    pingtai: h.shopSourceName,
                                                                    dianpu: h.shopName,
                                                                    store: h.shopSourceName + ',' + h.shopName,
                                                                    in3: false,
                                                                    created: h.created,
                                                                    sysMemo: h.sysMemo, // 系统备注
                                                                    sellerMemo: h.sellerMemo,// 卖家备注
                                                                    buyerMessage: h.buyerMessage,// 买家留言
                                                                    tagList: tagListArr.toString(),// 订单标签
                                                                })
                                                                // }
                                                            }
                                                        }
                                                        return orders;
                                                    },
                                                    getNewOrders_old: async function (param) {
                                                        // let endSelectTime = new Date(this.timeEnd);
                                                        // endSelectTime = new Date(endSelectTime.setMonth(endSelectTime.getMonth() + 1)).getTime();
                                                        // if (endSelectTime > new Date()) {
                                                        //     endSelectTime = new Date().getTime();
                                                        // }

                                                        // 获取三月内订单
                                                        let orders = [];
                                                        let ordersNew = await jerp.getData({
                                                            // title: '(1/4)获取三月内订单……',
                                                            url: '/trade/search',
                                                            api_name: 'trade_search',
                                                            return: 'data.list',
                                                        }, {
                                                            sid: param.orderInputStr,
                                                            outSid: param.expressInputStr,
                                                            useHasNext: 1,
                                                            queryId: 8,
                                                            timeType: 'pay_time',
                                                            startTime: param.startTime,
                                                            endTime: param.endTime,
                                                            userId: param.userId.toString(),
                                                            // sysStatus: 'FINISHED',
                                                            // containMemo: ,
                                                            order: 'desc',
                                                            field: 'pay_time',
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            pageNo: param.pageNo,
                                                            pageSize: param.pageSize,
                                                        }, false, param.getAll);
                                                        // console.log('ordersNew: ', ordersNew);
                                                        // let orderNewObj = {};
                                                        if (ordersNew && ordersNew.length > 0) {
                                                            for (let i = 0; i < ordersNew.length; i++) {
                                                                let h = ordersNew[i],
                                                                    tagListArr = [];
                                                                if (h.tagList != undefined && h.tagList.length > 0) h.tagList.map(v => tagListArr.push(v.tagName));
                                                                // if (h && h.b) {
                                                                orders.push({
                                                                    sid: h.b,
                                                                    tids: h.gd.toString(),
                                                                    shortId: h.ge,
                                                                    sysStatus: jerp.sysStatus[h.cl],
                                                                    outSid: h.y,
                                                                    expressPrintTime: h.bo,
                                                                    taobaoId: h.c,
                                                                    scalping: h.da ? true : false, // 空单
                                                                    pingtai: h.gt,
                                                                    dianpu: h.ai,
                                                                    store: h.gt + "," + h.ai,
                                                                    in3: true,
                                                                    created: h.g,
                                                                    sysMemo: h.cm, // 系统备注
                                                                    sellerMemo: h.ae,// 卖家备注
                                                                    buyerMessage: h.ad,// 买家留言
                                                                    tagList: tagListArr.toString(),// 订单标签
                                                                })
                                                                // orderNewObj[h.b] = '用于重复判定';
                                                                // }
                                                            }
                                                        }
                                                        // await jerp.sleep(100);
                                                        // console.log('orders: ', orders);
                                                        return orders;
                                                    },
                                                    setList_old: async function (reList, param) {
                                                        // console.log('param: ', param);
                                                        // return;
                                                        // console.log('listUnSort: ', listUnSort);
                                                        // jerp.pxmu.showload('(4/4)数据汇总处理...');
                                                        let self = this;
                                                        let goodsInfos = {};

                                                        // list去重
                                                        let list = [];
                                                        for (let i = 0; i < reList.length; i++) {
                                                            let h = reList[i];
                                                            if (!self.listObj[h.sid]) {
                                                                self.listObj[h.sid] = '已添加';
                                                                list.push(h);
                                                            }
                                                        }
                                                        // listObj = null;
                                                        // 重新排序
                                                        let index = self.list.length, orderSortObj = {}, expressSortObj = {};
                                                        if (param.orderInputStr != '' || param.expressInputStr != '') {
                                                            if (param.orderInputStr != '') {
                                                                param.orderInputStr.split(',').map(v => {
                                                                    orderSortObj[v] = index++;
                                                                });
                                                            }
                                                            if (param.expressInputStr != '') {
                                                                param.expressInputStr.split(',').map(v => {
                                                                    expressSortObj[v] = index++;
                                                                });
                                                            }
                                                            for (let i = 0; i < list.length; i++) {
                                                                let h = list[i];
                                                                h.sortIndex =
                                                                    orderSortObj[h.sid] !== undefined ?
                                                                        orderSortObj[h.sid] : (
                                                                            h.outSid !== undefined && expressSortObj[h.outSid] !== undefined ?
                                                                                expressSortObj[h.outSid] : index++
                                                                        );
                                                            }
                                                            list = list.sort((a, b) => { return a.sortIndex - b.sortIndex });
                                                        }
                                                        // console.log('list: ', list);
                                                        // return
                                                        // console.log('getAll: ', param.getAll, ', total: ', param.getAll ? (param.pageNo - 1) * param.pageSize + list.length : list.length);
                                                        // console.log("list: ", list);
                                                        for (let i = 0; i < list.length; i++) {
                                                            // while (1) {
                                                            //     await jerp.sleep(10);
                                                            //     if (self.xcNum < self.xc) {
                                                            //         break;
                                                            //     }
                                                            // }
                                                            // setTimeout(async () => {
                                                            //     self.xcNum++;
                                                            let h = list[i],
                                                                child = [], isPicked = '', jx = [], bz = [], dy = [],
                                                                expressDesc = "", expressTime = "", arrived = "";

                                                            if (param.filter.express.type != 0) {
                                                                if (h.in3) {
                                                                    if (h.tids) {
                                                                        let express = await jerp.getData({
                                                                            url: '/trade/logistics/trace/search',
                                                                            method: 'get',
                                                                            return: 'data',
                                                                        }, {
                                                                            'sid': h.sid,
                                                                            'taobaoId': h.taobaoId,
                                                                            'tid': h.tids
                                                                        });

                                                                        if ((express && express.length > 0) && (express[0].traceList && express[0].traceList.length > 0)) {
                                                                            let traceList = express[0].traceList,
                                                                                expressType = param.filter.express.child.isNew.type;

                                                                            if (param.filter.express.child.arrived.type != 0) {
                                                                                let accept = "",
                                                                                    sign = "";
                                                                                for (let i = 0; i < traceList.length; i++) {
                                                                                    if (
                                                                                        traceList[i].statusDesc.includes('已揽收') ||
                                                                                        traceList[i].statusDesc.includes('已取件') ||
                                                                                        traceList[i].statusDesc.includes('已收取')
                                                                                    ) {
                                                                                        accept = traceList[i].statusTime;
                                                                                    }
                                                                                    if (traceList[i].action == "SIGN") {
                                                                                        sign = traceList[i].statusTime;
                                                                                    }
                                                                                }
                                                                                if (accept == "") {
                                                                                    arrived = "快件未揽收";
                                                                                } else if (sign == "") {
                                                                                    arrived = "快件未到达";
                                                                                } else {
                                                                                    let start = new Date(accept).getTime(),
                                                                                        end = new Date(sign).getTime();
                                                                                    // console.log(arr);
                                                                                    let arr = parseInt((end - start) / (1000 * 60)); // min
                                                                                    // console.log(arr);
                                                                                    let d = parseInt(arr / (60 * 24));
                                                                                    let h = parseInt((arr / 60) % 24);
                                                                                    let m = arr % 60;
                                                                                    arrived = d + "天" + h + "时" + m + "分";
                                                                                    // arrived = ;
                                                                                }
                                                                            }
                                                                            // console.log("物流获取模式：", expressType);
                                                                            switch (expressType) {
                                                                                case 0: {
                                                                                    let trace = traceList[traceList.length - 1];
                                                                                    // console.log(h.sid, trace);
                                                                                    expressDesc = trace.statusDesc;
                                                                                    expressTime = trace.statusTime;
                                                                                    break;
                                                                                }
                                                                                case 1: {
                                                                                    for (let i = 0; i < traceList.length; i++) {
                                                                                        let trace = traceList[i];
                                                                                        if (
                                                                                            !trace.statusDesc.includes("等待揽收") &&
                                                                                            (trace.statusDesc.includes("取件") || trace.statusDesc.includes("揽收"))
                                                                                        ) {
                                                                                            expressDesc = trace.statusDesc;
                                                                                            expressTime = trace.statusTime;
                                                                                            break;
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                                default: {
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                } else {
                                                                    expressDesc = "超过物流查询日期";
                                                                }
                                                            }
                                                            if (param.filter.goodsDetail.type != 0 || param.filter.more.type != 0) {
                                                                let o = await jerp.getData({
                                                                    url: '/trade/detail',
                                                                    api_name: 'trade_detail',
                                                                    method: 'get',
                                                                    return: 'data',
                                                                }, {
                                                                    sid: h.sid,
                                                                });

                                                                if (param.filter.more.type != 0) {
                                                                    for (let j = 0; j < o.traces.length; j++) {
                                                                        let d = o.traces[j];
                                                                        let param = {
                                                                            operator: d.operator,
                                                                            content: d.content,
                                                                            operateTime: d.operateTime
                                                                        };
                                                                        if (d.action == "包装验货") {
                                                                            bz.push(param);
                                                                        }
                                                                        if (d.action.includes('拣选领单') || d.action.includes('安排拣选员')) {
                                                                            jx.push(param);
                                                                        }
                                                                        if (d.action.includes('打印快递单')) {
                                                                            dy.push(param);
                                                                        }
                                                                        if (d.content.includes('扣减货位库存')) {
                                                                            isPicked = '已发货';
                                                                        }
                                                                        // await jerp.sleep(10);
                                                                    }
                                                                }
                                                                if (param.filter.goodsDetail.type != 0) {
                                                                    if (o.orders && o.orders.length > 0) {
                                                                        for (let j = 0; j < o.orders.length; j++) {
                                                                            let d = o.orders[j], dList = [];
                                                                            if (d.suits) {
                                                                                for (let z = 0; z < d.suits.length; z++) {
                                                                                    let sd = d.suits[z];
                                                                                    dList.push(sd);
                                                                                }
                                                                            } else {
                                                                                dList.push(d);
                                                                            }
                                                                            // console.log('dList: ', dList);
                                                                            for (let z = 0; z < dList.length; z++) {
                                                                                let dd = dList[z];
                                                                                // console.log('outerId: ', outerId);
                                                                                if (dd.outerId != undefined && dd.outerId != null && dd.outerId != "") {
                                                                                    if (!goodsInfos[dd.outerId]) {
                                                                                        goodsInfos[dd.outerId] = {
                                                                                            xcCodes: [],
                                                                                            xcTotalNum: 0,
                                                                                            xcLockNum: 0,
                                                                                            bhCodes: [],
                                                                                            bhTotalNum: 0,
                                                                                            bhLockNum: 0,
                                                                                            supplierName: "",
                                                                                        }
                                                                                        if (param.filter.goodsDetail.child.goodsStock.type != 0) {
                                                                                            let codes = await self.getGoodsCode(dd.outerId, self.warehouse);
                                                                                            if (codes.length > 0) {
                                                                                                for (let i = 0; i < codes.length; i++) {
                                                                                                    let c = codes[i];
                                                                                                    if (c.stockRegionName.includes('备货')) {
                                                                                                        goodsInfos[dd.outerId].bhCodes.push(jerp.setCodeName(c.code));
                                                                                                        goodsInfos[dd.outerId].bhTotalNum += c.sku.totalNum;
                                                                                                        goodsInfos[dd.outerId].bhLockNum += c.sku.lockNum;
                                                                                                    } else {
                                                                                                        goodsInfos[dd.outerId].xcCodes.push(jerp.setCodeName(c.code));
                                                                                                        goodsInfos[dd.outerId].xcTotalNum += c.sku.totalNum;
                                                                                                        goodsInfos[dd.outerId].xcLockNum += c.sku.lockNum;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            if (self.warehouse2 != "") {
                                                                                                codes = await self.getGoodsCode(dd.outerId, self.warehouse2); // 备货仓
                                                                                                if (codes.length > 0) {
                                                                                                    for (let i = 0; i < codes.length; i++) {
                                                                                                        let c = codes[i];
                                                                                                        goodsInfos[dd.outerId].bhCodes.push(jerp.setCodeName(c.code));
                                                                                                        goodsInfos[dd.outerId].bhTotalNum += c.sku.totalNum;
                                                                                                        goodsInfos[dd.outerId].bhLockNum += c.sku.lockNum;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        // if (param.filter.goodsDetail.child.goodsStock.type != 0) {
                                                                                        if (dd.supplierName != "") {
                                                                                            goodsInfos[dd.outerId].supplierName = dd.supplierName;
                                                                                        } else {
                                                                                            let ginfo = await jerp.getData({
                                                                                                url: '/item/queryItemV2Reference',
                                                                                                method: 'post',
                                                                                                return: 'data',
                                                                                            }, {
                                                                                                api_name: 'item_queryItemV2Reference',
                                                                                                itemIdInfo: `[{ "sysItemId": ${dd.itemSysId}, "sysSkuId": 0 }]`,
                                                                                            });
                                                                                            if (ginfo.length > 0 && ginfo[0].supplierBridgeList.length > 0) {
                                                                                                goodsInfos[dd.outerId].supplierName = ginfo[0].supplierBridgeList[0].supplierName;
                                                                                            }
                                                                                        }
                                                                                        // }
                                                                                    }
                                                                                    child.push({
                                                                                        outerId: dd.outerId,
                                                                                        title: dd.title,
                                                                                        num: dd.num,
                                                                                        supplierName: goodsInfos[dd.outerId].supplierName,
                                                                                        status: jerp.sysStatus[dd.unifiedStatus] ? jerp.sysStatus[dd.unifiedStatus] : dd.unifiedStatus,// status
                                                                                        xcCodes: goodsInfos[dd.outerId].xcCodes.toString(),
                                                                                        xcTotalNum: goodsInfos[dd.outerId].xcTotalNum,
                                                                                        xcLockNum: goodsInfos[dd.outerId].xcLockNum,
                                                                                        bhCodes: goodsInfos[dd.outerId].bhCodes.toString(),
                                                                                        bhTotalNum: goodsInfos[dd.outerId].bhTotalNum,
                                                                                        bhLockNum: goodsInfos[dd.outerId].bhLockNum,
                                                                                    });
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                            self.list.push({
                                                                sortIndex: h.sortIndex,
                                                                sid: h.sid,
                                                                tids: h.tids,
                                                                shortId: h.shortId,
                                                                sysStatus: jerp.sysStatus[h.sysStatus] ? jerp.sysStatus[h.sysStatus] : h.sysStatus,
                                                                outSid: h.outSid ? h.outSid : (dy.length > 0 ? dy[0].content : ''),
                                                                expressPrintTime: h.expressPrintTime != "" ? jerp.getFormatDate(new Date(h.expressPrintTime), 'yyyy-MM-dd') : "",
                                                                pingtai: h.pingtai,
                                                                dianpu: h.dianpu,
                                                                store: h.store,
                                                                created: jerp.getFormatDate(new Date(h.created), 'yyyy-MM-dd'),
                                                                child: child,
                                                                isPicked: isPicked,
                                                                jx: jx.length > 0 ? jx[0].operator + ' | ' + jerp.getFormatDate(new Date(jx[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                jx_operator: jx.length > 0 ? jx[0].operator : '',
                                                                jx_operateTime: jx.length > 0 ? jerp.getFormatDate(new Date(jx[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                bz: bz.length > 0 ? bz[0].operator + ' | ' + jerp.getFormatDate(new Date(bz[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                bz_operator: bz.length > 0 ? bz[0].operator : '',
                                                                bz_operateTime: bz.length > 0 ? jerp.getFormatDate(new Date(bz[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                // dy: dy,
                                                                arrived: arrived,
                                                                expressTime: expressTime,
                                                                expressDesc: expressDesc,
                                                                sysMemo: h.sysMemo, // 系统备注
                                                                sellerMemo: h.sellerMemo,// 卖家备注
                                                                buyerMessage: h.buyerMessage,// 买家留言
                                                                tagList: h.tagList,// 订单标签
                                                            });
                                                            // await jerp.sleep(1);
                                                            self.updateTitle(Object.keys(self.listObj).length, param.filter);
                                                            self.xcNum--;
                                                            // }, 0);
                                                        }

                                                        // this.copyAvailable = true;
                                                        // jerp.pxmu.closeload();
                                                    },
                                                    check: async function (event) {
                                                        this.jTable.footer.nowTabInput = 1;
                                                        this.jTable.footer.nowTab = 1;

                                                        if (event != undefined) {
                                                            let tar = event.target;
                                                            tar.setSelectionRange(0, tar.value.length);
                                                        }
                                                        // console.log(event);
                                                        // return;
                                                        if (this.timeStart == '' || this.timeEnd == "") { jerp.pxmu.toast('请填写正确的时间!'); return []; }
                                                        if (this.getAll == false &&
                                                            this.orderInputStr == "" && this.expressInputStr == "" &&
                                                            new Date(this.timeEnd).getTime() - new Date(this.timeStart).getTime() > 864000000) {
                                                            // console.log(new Date(this.timeEnd).getTime() - new Date(this.timeStart).getTime());
                                                            jerp.pxmu.toast('查询数据量较大，请勾选分段获取');
                                                            return;
                                                        }
                                                        // return;
                                                        jerp.pxmu.showload('数据加载中...');
                                                        let self = this,
                                                            startTime = new Date(this.timeStart).getTime(),
                                                            endTime = new Date(this.timeEnd).getTime(),
                                                            filter = JSON.parse(JSON.stringify(this.filter));
                                                        self.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                        self.updateTitle(0, filter);
                                                        self.copyAvailable = false;
                                                        self.list = [];
                                                        self.listObj = {};

                                                        // 去除重复项
                                                        let checkType = self.multiSelect.checkType, checkInputStr = '', userId = [];
                                                        if (self.multiSelect.checkInputStr != '') {
                                                            let orderList = [], orderObj = {};
                                                            let multiStrList = self.multiSelect.checkInputStr.split(',');
                                                            if (multiStrList.length > 0) {
                                                                for (let i = 0; i < multiStrList.length; i++) {
                                                                    let sid = multiStrList[i];
                                                                    if (!orderObj[sid]) {
                                                                        orderList.push(sid);
                                                                        orderObj[sid] = '已添加';
                                                                    }
                                                                }
                                                                checkInputStr = orderList.toString();
                                                            }
                                                        }

                                                        self.bindShops.map(v => { if (v.status) userId.push(v.userId); });
                                                        let param = { getAll: !self.getAll, checkType, checkInputStr, userId, startTime, endTime, filter, pageNo: 1, pageSize: 1000 };
                                                        if (param.getAll) {
                                                            let newOrders = await self.getNewOrders(param);
                                                            let oldOrders = await self.getOldOrders(param);
                                                            let orders = [...newOrders, ...oldOrders];
                                                            // console.log(orders);
                                                            if (orders.length == 0) { jerp.pxmu.toast('未查询到相关单据...'); jerp.pxmu.closeload(); return; }
                                                            await self.setList(orders, param);
                                                            self.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                        } else {
                                                            param.pageNo = 1;
                                                            while (1) {
                                                                let newOrders = await self.getNewOrders(param);
                                                                await self.setList(newOrders, param);
                                                                if (newOrders.length == 0 || newOrders.length < param.pageSize) {
                                                                    break;
                                                                }
                                                                param.pageNo += 1;
                                                                await jerp.sleep(1000);
                                                            }
                                                            param.pageNo = 1;
                                                            while (1) {
                                                                let oldOrders = await self.getOldOrders(param);
                                                                await self.setList(oldOrders, param);
                                                                if (oldOrders.length == 0 || oldOrders.length < param.pageSize) {
                                                                    break;
                                                                }
                                                                param.pageNo += 1;
                                                                await jerp.sleep(1000);
                                                            }
                                                            self.copyAvailable = true;
                                                            jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    getOldOrders: async function (param) {
                                                        let orders = [];
                                                        // 获取三月前的归档订单
                                                        let ordersOld = await jerp.getData({
                                                            // title: '(2/4)获取归档订单……',
                                                            url: '/trade/search3month',
                                                            api_name: 'trade_search3month',
                                                            return: 'data.list',
                                                        }, {
                                                            [param.checkType]: param.checkInputStr,
                                                            // sid: param.orderInputStr,
                                                            // outSid: param.expressInputStr,
                                                            timeType: 'pay_time',
                                                            dateTypeSelect: 0,
                                                            startTime: param.startTime,
                                                            endTime: param.endTime,
                                                            userId: param.userId.toString(),
                                                            highlight: false,
                                                            field: 'pay_time',
                                                            order: 'asc',
                                                            queryId: 9,
                                                            queryOrder: 0,
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            pageNo: param.pageNo,
                                                            pageSize: param.pageSize,
                                                        }, false, param.getAll);
                                                        // console.log('ordersOld: ', ordersOld);
                                                        if (ordersOld && ordersOld.length > 0) {
                                                            for (let i = 0; i < ordersOld.length; i++) {
                                                                let h = ordersOld[i],
                                                                    tagListArr = [];
                                                                if (h.tagList != undefined && h.tagList.length > 0) h.tagList.map(v => tagListArr.push(v.tagName));
                                                                // console.log(h, h && h.sid && !orderNewObj[h.sid]);
                                                                // if (h && h.sid && !orderNewObj[h.sid]) {
                                                                orders.push({
                                                                    sid: h.sid,
                                                                    tids: h.tids.length > 0 ? h.tids.toString() : h.tid,
                                                                    shortId: h.shortId,
                                                                    sysStatus: h.chStatus,
                                                                    outSid: h.outSid,
                                                                    expressPrintTime: h.expressPrintTime,
                                                                    taobaoId: h.taobaoId,
                                                                    scalping: h.scalping ? true : false, // 空单
                                                                    pingtai: h.shopSourceName,
                                                                    dianpu: h.shopName,
                                                                    store: h.shopSourceName + ',' + h.shopName,
                                                                    in3: false,
                                                                    created: h.created,
                                                                    sysMemo: h.sysMemo, // 系统备注
                                                                    sellerMemo: h.sellerMemo,// 卖家备注
                                                                    buyerMessage: h.buyerMessage,// 买家留言
                                                                    tagList: tagListArr.toString(),// 订单标签
                                                                })
                                                                // }
                                                            }
                                                        }
                                                        return orders;
                                                    },
                                                    getNewOrders: async function (param) {
                                                        // let endSelectTime = new Date(this.timeEnd);
                                                        // endSelectTime = new Date(endSelectTime.setMonth(endSelectTime.getMonth() + 1)).getTime();
                                                        // if (endSelectTime > new Date()) {
                                                        //     endSelectTime = new Date().getTime();
                                                        // }

                                                        // 获取三月内订单
                                                        let orders = [];
                                                        let ordersNew = await jerp.getData({
                                                            // title: '(1/4)获取三月内订单……',
                                                            url: '/trade/search',
                                                            api_name: 'trade_search',
                                                            return: 'data.list',
                                                        }, {
                                                            [param.checkType]: param.checkInputStr,
                                                            // sid: param.orderInputStr,
                                                            // outSid: param.expressInputStr,
                                                            useHasNext: 1,
                                                            queryId: 8,
                                                            timeType: 'pay_time',
                                                            startTime: param.startTime,
                                                            endTime: param.endTime,
                                                            userId: param.userId.toString(),
                                                            // sysStatus: 'FINISHED',
                                                            // containMemo: ,
                                                            order: 'desc',
                                                            field: 'pay_time',
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            pageNo: param.pageNo,
                                                            pageSize: param.pageSize,
                                                        }, false, param.getAll);
                                                        // console.log('ordersNew: ', ordersNew);
                                                        // let orderNewObj = {};
                                                        if (ordersNew && ordersNew.length > 0) {
                                                            for (let i = 0; i < ordersNew.length; i++) {
                                                                let h = ordersNew[i],
                                                                    tagListArr = [];
                                                                if (h.tagList != undefined && h.tagList.length > 0) h.tagList.map(v => tagListArr.push(v.tagName));
                                                                // if (h && h.b) {
                                                                orders.push({
                                                                    sid: h.b,
                                                                    tids: h.gd.toString(),
                                                                    shortId: h.ge,
                                                                    sysStatus: jerp.sysStatus[h.cl],
                                                                    outSid: h.y,
                                                                    expressPrintTime: h.bo,
                                                                    taobaoId: h.c,
                                                                    scalping: h.da ? true : false, // 空单
                                                                    pingtai: h.gt,
                                                                    dianpu: h.ai,
                                                                    store: h.gt + "," + h.ai,
                                                                    in3: true,
                                                                    created: h.g,
                                                                    sysMemo: h.cm, // 系统备注
                                                                    sellerMemo: h.ae,// 卖家备注
                                                                    buyerMessage: h.ad,// 买家留言
                                                                    tagList: tagListArr.toString(),// 订单标签
                                                                })
                                                                // orderNewObj[h.b] = '用于重复判定';
                                                                // }
                                                            }
                                                        }
                                                        // await jerp.sleep(100);
                                                        // console.log('orders: ', orders);
                                                        return orders;
                                                    },
                                                    // 5576059602742467
                                                    setList: async function (reList, param) {
                                                        // console.log('param: ', param);
                                                        // return;
                                                        // console.log('listUnSort: ', listUnSort);
                                                        // jerp.pxmu.showload('(4/4)数据汇总处理...');
                                                        let self = this;

                                                        // list去重
                                                        let list = [];
                                                        for (let i = 0; i < reList.length; i++) {
                                                            let h = reList[i];
                                                            if (!self.listObj[h.sid]) {
                                                                self.listObj[h.sid] = '已添加';
                                                                list.push(h);
                                                            }
                                                        }
                                                        // list排序
                                                        let goodsInfos = {}, sortObj = {}, index = 1,
                                                            checkType = self.multiSelect.checkType == "tid" ? "tids" : self.multiSelect.checkType;
                                                        self.multiSelect.checkInputStr.split(",").map(v => { if (!sortObj[v]) { sortObj[v] = index++; } })
                                                        list = list.sort((a, b) => {
                                                            return sortObj[a[checkType]] - sortObj[b[checkType]];
                                                        })
                                                        // listObj = null;
                                                        // 重新排序
                                                        // let index = self.list.length, orderSortObj = {}, expressSortObj = {};
                                                        // if (param.checkInputStr != '') {
                                                        //     param.checkInputStr.split(',').map(v => {
                                                        //         orderSortObj[v] = index++;
                                                        //     });
                                                        // }

                                                        for (let i = 0; i < list.length; i++) {
                                                            // while (1) {
                                                            //     await jerp.sleep(10);
                                                            //     if (self.xcNum < self.xc) {
                                                            //         break;
                                                            //     }
                                                            // }
                                                            // setTimeout(async () => {
                                                            //     self.xcNum++;
                                                            let h = list[i],
                                                                child = [], isPicked = '', jx = [], bz = [], dy = [],
                                                                expressDesc = "", expressTime = "", arrived = "";

                                                            if (param.filter.express.type != 0) {
                                                                if (h.in3) {
                                                                    if (h.tids) {
                                                                        let express = await jerp.getData({
                                                                            url: '/trade/logistics/trace/search',
                                                                            method: 'get',
                                                                            return: 'data',
                                                                        }, {
                                                                            'sid': h.sid,
                                                                            'taobaoId': h.taobaoId,
                                                                            'tid': h.tids
                                                                        });

                                                                        if ((express && express.length > 0) && (express[0].traceList && express[0].traceList.length > 0)) {
                                                                            let traceList = express[0].traceList,
                                                                                expressType = param.filter.express.child.isNew.type;

                                                                            if (param.filter.express.child.arrived.type != 0) {
                                                                                let accept = "",
                                                                                    sign = "";
                                                                                for (let i = 0; i < traceList.length; i++) {
                                                                                    if (
                                                                                        traceList[i].statusDesc.includes('已揽收') ||
                                                                                        traceList[i].statusDesc.includes('已取件') ||
                                                                                        traceList[i].statusDesc.includes('已收取')
                                                                                    ) {
                                                                                        accept = traceList[i].statusTime;
                                                                                    }
                                                                                    if (traceList[i].action == "SIGN") {
                                                                                        sign = traceList[i].statusTime;
                                                                                    }
                                                                                }
                                                                                if (accept == "") {
                                                                                    arrived = "快件未揽收";
                                                                                } else if (sign == "") {
                                                                                    arrived = "快件未到达";
                                                                                } else {
                                                                                    let start = new Date(accept).getTime(),
                                                                                        end = new Date(sign).getTime();
                                                                                    // console.log(arr);
                                                                                    let arr = parseInt((end - start) / (1000 * 60)); // min
                                                                                    // console.log(arr);
                                                                                    let d = parseInt(arr / (60 * 24));
                                                                                    let h = parseInt((arr / 60) % 24);
                                                                                    let m = arr % 60;
                                                                                    arrived = d + "天" + h + "时" + m + "分";
                                                                                    // arrived = ;
                                                                                }
                                                                            }
                                                                            // console.log("物流获取模式：", expressType);
                                                                            switch (expressType) {
                                                                                case 0: {
                                                                                    let trace = traceList[traceList.length - 1];
                                                                                    // console.log(h.sid, trace);
                                                                                    expressDesc = trace.statusDesc;
                                                                                    expressTime = trace.statusTime;
                                                                                    break;
                                                                                }
                                                                                case 1: {
                                                                                    for (let i = 0; i < traceList.length; i++) {
                                                                                        let trace = traceList[i];
                                                                                        if (
                                                                                            !trace.statusDesc.includes("等待揽收") &&
                                                                                            (trace.statusDesc.includes("取件") || trace.statusDesc.includes("揽收"))
                                                                                        ) {
                                                                                            expressDesc = trace.statusDesc;
                                                                                            expressTime = trace.statusTime;
                                                                                            break;
                                                                                        }
                                                                                    }
                                                                                    break;
                                                                                }
                                                                                default: {
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                } else {
                                                                    expressDesc = "超过物流查询日期";
                                                                }
                                                            }
                                                            if (param.filter.goodsDetail.type != 0 || param.filter.more.type != 0) {
                                                                let o = await jerp.getData({
                                                                    url: '/trade/detail',
                                                                    api_name: 'trade_detail',
                                                                    method: 'get',
                                                                    return: 'data',
                                                                }, {
                                                                    sid: h.sid,
                                                                });

                                                                if (param.filter.more.type != 0) {
                                                                    for (let j = 0; j < o.traces.length; j++) {
                                                                        let d = o.traces[j];
                                                                        let param = {
                                                                            operator: d.operator,
                                                                            content: d.content,
                                                                            operateTime: d.operateTime
                                                                        };
                                                                        if (d.action == "包装验货") {
                                                                            bz.push(param);
                                                                        }
                                                                        if (d.action.includes('拣选领单') || d.action.includes('安排拣选员')) {
                                                                            jx.push(param);
                                                                        }
                                                                        if (d.action.includes('打印快递单')) {
                                                                            dy.push(param);
                                                                        }
                                                                        if (d.content.includes('扣减货位库存')) {
                                                                            isPicked = '已发货';
                                                                        }
                                                                        // await jerp.sleep(10);
                                                                    }
                                                                }
                                                                if (param.filter.goodsDetail.type != 0) {
                                                                    if (o.orders && o.orders.length > 0) {
                                                                        for (let j = 0; j < o.orders.length; j++) {
                                                                            let d = o.orders[j], dList = [];
                                                                            if (d.suits) {
                                                                                for (let z = 0; z < d.suits.length; z++) {
                                                                                    let sd = d.suits[z];
                                                                                    dList.push(sd);
                                                                                }
                                                                            } else {
                                                                                dList.push(d);
                                                                            }
                                                                            // console.log('dList: ', dList);
                                                                            for (let z = 0; z < dList.length; z++) {
                                                                                let dd = dList[z];
                                                                                // console.log('outerId: ', outerId);
                                                                                if (dd.outerId != undefined && dd.outerId != null && dd.outerId != "") {
                                                                                    if (!goodsInfos[dd.outerId]) {
                                                                                        goodsInfos[dd.outerId] = {
                                                                                            xcCodes: [],
                                                                                            xcTotalNum: 0,
                                                                                            xcLockNum: 0,
                                                                                            bhCodes: [],
                                                                                            bhTotalNum: 0,
                                                                                            bhLockNum: 0,
                                                                                            supplierName: "",
                                                                                        }
                                                                                        if (param.filter.goodsDetail.child.goodsStock.type != 0) {
                                                                                            if (self.warehouse != "") {
                                                                                                let codes = await self.getGoodsCode(dd.outerId, self.warehouse);
                                                                                                // console.log('warehouse1: ', self.warehouse, codes);
                                                                                                if (codes.length > 0) {
                                                                                                    for (let i = 0; i < codes.length; i++) {
                                                                                                        let c = codes[i];
                                                                                                        if (c.stockRegionName.includes('备货')) {
                                                                                                            goodsInfos[dd.outerId].bhCodes.push(jerp.setCodeName(c.code));
                                                                                                            goodsInfos[dd.outerId].bhTotalNum += c.sku.totalNum;
                                                                                                            goodsInfos[dd.outerId].bhLockNum += c.sku.lockNum;
                                                                                                        } else {
                                                                                                            goodsInfos[dd.outerId].xcCodes.push(jerp.setCodeName(c.code));
                                                                                                            goodsInfos[dd.outerId].xcTotalNum += c.sku.totalNum;
                                                                                                            goodsInfos[dd.outerId].xcLockNum += c.sku.lockNum;
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            if (self.warehouse2 != "") {
                                                                                                let codes2 = await self.getGoodsCode(dd.outerId, self.warehouse2); // 备货仓
                                                                                                // console.log('warehouse2: ', self.warehouse2, codes2);
                                                                                                if (codes2.length > 0) {
                                                                                                    for (let i = 0; i < codes2.length; i++) {
                                                                                                        let c = codes2[i];
                                                                                                        goodsInfos[dd.outerId].bhCodes.push(jerp.setCodeName(c.code));
                                                                                                        goodsInfos[dd.outerId].bhTotalNum += c.sku.totalNum;
                                                                                                        goodsInfos[dd.outerId].bhLockNum += c.sku.lockNum;
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        // if (param.filter.goodsDetail.child.goodsStock.type != 0) {
                                                                                        if (dd.supplierName != "") {
                                                                                            goodsInfos[dd.outerId].supplierName = dd.supplierName;
                                                                                        } else {
                                                                                            let ginfo = await jerp.getData({
                                                                                                url: '/item/queryItemV2Reference',
                                                                                                method: 'post',
                                                                                                return: 'data',
                                                                                            }, {
                                                                                                api_name: 'item_queryItemV2Reference',
                                                                                                itemIdInfo: `[{ "sysItemId": ${dd.itemSysId}, "sysSkuId": 0 }]`,
                                                                                            });
                                                                                            if (ginfo.length > 0 && ginfo[0].supplierBridgeList.length > 0) {
                                                                                                goodsInfos[dd.outerId].supplierName = ginfo[0].supplierBridgeList[0].supplierName;
                                                                                            }
                                                                                        }
                                                                                        // }
                                                                                    }
                                                                                    child.push({
                                                                                        outerId: dd.outerId,
                                                                                        title: dd.title,
                                                                                        num: dd.num,
                                                                                        supplierName: goodsInfos[dd.outerId].supplierName,
                                                                                        status: jerp.sysStatus[dd.unifiedStatus] ? jerp.sysStatus[dd.unifiedStatus] : dd.unifiedStatus,// status
                                                                                        xcCodes: goodsInfos[dd.outerId].xcCodes.toString(),
                                                                                        xcTotalNum: goodsInfos[dd.outerId].xcTotalNum,
                                                                                        xcLockNum: goodsInfos[dd.outerId].xcLockNum,
                                                                                        bhCodes: goodsInfos[dd.outerId].bhCodes.toString(),
                                                                                        bhTotalNum: goodsInfos[dd.outerId].bhTotalNum,
                                                                                        bhLockNum: goodsInfos[dd.outerId].bhLockNum,
                                                                                    });
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }

                                                            self.list.push({
                                                                sortIndex: h.sortIndex,
                                                                sid: h.sid,
                                                                tids: h.tids,
                                                                shortId: h.shortId,
                                                                sysStatus: jerp.sysStatus[h.sysStatus] ? jerp.sysStatus[h.sysStatus] : h.sysStatus,
                                                                outSid: h.outSid ? h.outSid : (dy.length > 0 ? dy[0].content : ''),
                                                                expressPrintTime: h.expressPrintTime != "" ? jerp.getFormatDate(new Date(h.expressPrintTime), 'yyyy-MM-dd') : "",
                                                                pingtai: h.pingtai,
                                                                dianpu: h.dianpu,
                                                                store: h.store,
                                                                created: jerp.getFormatDate(new Date(h.created), 'yyyy-MM-dd'),
                                                                child: child,
                                                                isPicked: isPicked,
                                                                jx: jx.length > 0 ? jx[0].operator + ' | ' + jerp.getFormatDate(new Date(jx[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                jx_operator: jx.length > 0 ? jx[0].operator : '',
                                                                jx_operateTime: jx.length > 0 ? jerp.getFormatDate(new Date(jx[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                bz: bz.length > 0 ? bz[0].operator + ' | ' + jerp.getFormatDate(new Date(bz[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                bz_operator: bz.length > 0 ? bz[0].operator : '',
                                                                bz_operateTime: bz.length > 0 ? jerp.getFormatDate(new Date(bz[0].operateTime), 'yyyy-MM-dd HH:mm:ss') : '',
                                                                // dy: dy,
                                                                arrived: arrived,
                                                                expressTime: expressTime,
                                                                expressDesc: expressDesc,
                                                                sysMemo: h.sysMemo, // 系统备注
                                                                sellerMemo: h.sellerMemo,// 卖家备注
                                                                buyerMessage: h.buyerMessage,// 买家留言
                                                                tagList: h.tagList,// 订单标签
                                                            });
                                                            // await jerp.sleep(1);
                                                            self.updateTitle(Object.keys(self.listObj).length, param.filter);
                                                            self.xcNum--;
                                                            // }, 0);
                                                        }

                                                        // this.copyAvailable = true;
                                                        // jerp.pxmu.closeload();
                                                    },
                                                    getOrderExpress: function (sid) {
                                                        return new Promise(resolve => {
                                                            $.ajax({
                                                                url: location.origin + '/trade/detail',
                                                                method: 'get',
                                                                dataType: 'json',
                                                                async: false,
                                                                data: {
                                                                    api_name: 'rade_trace_detail',
                                                                    sid: sid
                                                                },
                                                                success: function (e) {
                                                                    if (e && e.clueId) {
                                                                        let taobaoId = e.data.taobaoId;
                                                                        let tid = e.data.tid;
                                                                        $.ajax({
                                                                            url: location.origin + '/trade/logistics/trace/search',
                                                                            method: 'get',
                                                                            dataType: 'json',
                                                                            async: true,
                                                                            data: { 'sid': sid, 'taobaoId': taobaoId, 'tid': tid },
                                                                            success: function (e) {
                                                                                if (e && e.clueId) {
                                                                                    let traceList = e.data[0].traceList;
                                                                                    if (traceList && traceList.length > 0) {
                                                                                        let statusDesc = traceList[traceList.length - 1].statusDesc;
                                                                                        resolve(statusDesc);
                                                                                    } else {
                                                                                        resolve('');
                                                                                    }
                                                                                } else {
                                                                                    jerp.pxmu.toast('错误：请联系管理员！');
                                                                                    resolve(false);
                                                                                }
                                                                            },
                                                                            error: function () {
                                                                                resolve(false);
                                                                            }
                                                                        });
                                                                    } else {
                                                                        jerp.pxmu.toast('错误：请联系管理员！');
                                                                        resolve(false);
                                                                    }
                                                                },
                                                                error: function () {
                                                                    resolve(false);
                                                                }
                                                            });
                                                        });
                                                    },
                                                    getGoodsCode: async function (outerId, warehouseId) {
                                                        let self = this;
                                                        return await jerp.getData({
                                                            url: '/wms/goodsSectionInventory/list',
                                                            method: 'post',
                                                            return: 'data.list',
                                                        }, {
                                                            "userId": -1,
                                                            "warehouseId": warehouseId,
                                                            "stockRegionIds": "",
                                                            "goodsSectionCode": "",
                                                            "text": outerId,
                                                            "queryOuterIdType": "1",
                                                            "queryParams": [
                                                                {
                                                                    "queryType": "title",
                                                                    "queryText": ""
                                                                },
                                                                {
                                                                    "queryType": "propertiesName",
                                                                    "queryText": ""
                                                                }
                                                            ],
                                                            "supplierNames": "",
                                                            "supplierIds": [],
                                                            "categoryNameStr": null,
                                                            "multiCode": "",
                                                            "stockRegionType": "",
                                                            "productTimeStart": "",
                                                            "productTimeEnd": "",
                                                            "batchNo": "",
                                                            "hasBatch": "",
                                                            "hasProduct": "",
                                                            "page": {
                                                                "pageNo": 1,
                                                                "pageSize": 50
                                                            }
                                                        }, true);
                                                    },
                                                    export2Excel: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let self = this,
                                                            content = '',
                                                            copyList = {
                                                                _index: '序号',
                                                                sid: '系统单号',
                                                                tids: '平台单号',
                                                                pingtai: '平台',
                                                                dianpu: '店铺',
                                                                sysStatus: '订单状态',
                                                                outSid: '快递单号',
                                                                expressPrintTime: "打印时间",
                                                                created: '下单日期',
                                                            },
                                                            copyListSub = {},
                                                            exData = [];

                                                        if (self.filter.goodsDetail.child.goodsStock.type != 0) {
                                                            copyListSub = { supplierName: '供应商' };
                                                        }
                                                        copyListSub = {
                                                            ...copyListSub, ...{
                                                                supplierName: '供应商',
                                                                outerId: '商品编码',
                                                                title: '商品名称',
                                                                num: '数量',
                                                            }
                                                        };
                                                        if (self.filter.goodsDetail.child.goodsStock.type != 0) {
                                                            copyListSub = {
                                                                ...copyListSub, ...{
                                                                    xcCodes: '新仓货位',
                                                                    xcTotalNum: '数量',
                                                                    bhCodes: '备货货位',
                                                                    bhTotalNum: '数量',
                                                                }
                                                            };
                                                        }
                                                        copyListSub = {
                                                            ...copyListSub, ...{
                                                                status: '商品状态',
                                                            }
                                                        };
                                                        if (self.DLRemark) {
                                                            copyList = {
                                                                ...copyList, ...{
                                                                    sysMemo: "系统备注",
                                                                    sellerMemo: "卖家备注",
                                                                    buyerMessage: "买家留言",
                                                                    tagList: "订单标签",
                                                                }
                                                            };
                                                        }
                                                        if (self.filter.more.type != 0) {
                                                            if (self.filter.more.child.isJX.type != 0) {
                                                                copyList = {
                                                                    ...copyList, ...{
                                                                        jx_operator: '拣选员',
                                                                        jx_operateTime: '拣选时间',
                                                                    }
                                                                };
                                                            }
                                                            if (self.filter.more.child.isBZ.type != 0) {
                                                                copyList = {
                                                                    ...copyList, ...{
                                                                        bz_operator: '包装员',
                                                                        bz_operateTime: '包装时间',

                                                                    }
                                                                };
                                                            }
                                                            if (self.filter.more.child.isPicked.type != 0) {
                                                                copyList = {
                                                                    ...copyList, ...{
                                                                        isPicked: '已出库',
                                                                    }
                                                                };
                                                            }
                                                        }
                                                        if (self.filter.express.type != 0) {
                                                            copyList = {
                                                                ...copyList, ...{
                                                                    expressDesc: '物流描述',
                                                                    expressTime: '物流时间',
                                                                }
                                                            };
                                                        }
                                                        let title = [];
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            title.push(copyList[i]);
                                                        }
                                                        if (self.filter.goodsDetail.type != 0) {
                                                            for (let i in copyListSub) {
                                                                title.push(copyListSub[i]);
                                                            }
                                                        }
                                                        exData.push(title);
                                                        let index = 0;
                                                        for (let i = 0; i < self.list.length; i++) {
                                                            let h = self.list[i];
                                                            if (self.filter.goodsDetail.type != 0 && h.child.length > 0) {
                                                                for (let j = 0; j < h.child.length; j++) {
                                                                    let c = h.child[j],
                                                                        row = [];
                                                                    for (let a in copyList) {
                                                                        switch (a) {
                                                                            case '_index': {
                                                                                row.push(j == 0 ? ++index : '');
                                                                                break;
                                                                            }
                                                                            default: {
                                                                                row.push(j == 0 || self.FillInfo ? h[a] : '');
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                    for (let b in copyListSub) {
                                                                        row.push(c[b]);
                                                                    }
                                                                    exData.push(row);
                                                                }
                                                            } else {
                                                                let row = [];
                                                                for (let a in copyList) {
                                                                    switch (a) {
                                                                        case '_index': {
                                                                            row.push(++index);
                                                                            break;
                                                                        }
                                                                        default: {
                                                                            row.push(h[a]);
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                                exData.push(row);
                                                            }
                                                        }
                                                        jerp.sheet.export(exData, '订单查询');
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 新建订单
                                        name: '新建订单',
                                        subName: '补单',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '云淡风轻', '金榜', "文员", "文员2"],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="flex-flow: column;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" style="flex-flow: column; flex: 2">
                                                            <div class="jerpRow">
                                                                <div class="jerpCol">
                                                                    <span>店铺：</span>
                                                                    <select style="width: 8rem;" v-model="submitInfo.userId">
                                                                        <option value="" disabled="true" selected="true">请选择店铺</option>
                                                                        <option v-for="item in bindShopList" :value="item.userId">{{item.sourceName}}-{{item.priorityTitle}}</option>
                                                                    </select>
                                                                </div>
                                                                <div class="jerpCol">
                                                                    <!-- <input type="checkbox" v-model="isBlank">空单</input> -->
                                                                    <input type="checkbox" v-model="isReissue">补发</input>
                                                                    <span> 类型：</span>
                                                                    <select v-model="supOrder.supType" :disabled='isReissue==false?true:false'>
                                                                        <option v-for="(item,index) in supOrder.supTypeList" :value="index">{{item.name}}</option>
                                                                    </select>
                                                                    <input type="text" v-model="originOrderPick" placeholder="输入原订单快递号" :disabled='isReissue==false?true:false' @keyup.enter="selectOriginOrder"></input>
                                                                    <button class="btn" @click="selectOriginOrder" :disabled='isReissue==false?true:false'>加载</button>
                                                                </div>
                                                            </div>
                                                            <div class="jerpRow">
                                                                <div class="jerpCol">
                                                                    <span>仓库：</span>
                                                                    <select style="width: 8rem;" v-model="warehouse" :disabled='submitInfo.userId==""?true:false'>
                                                                        <option value="" disabled="true" selected="true">请选择仓库</option>
                                                                        <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                                    </select>
                                                                </div>
                                                                <div class="jerpCol" style="margin-left: 1rem;">
                                                                    <input type="checkbox" v-model="showMore" style="margin: 0" :disabled='submitInfo.userId==""?true:false'>显示更多</input>
                                                                </div>
                                                                <div class="jerpCol" style="margin-left: 1rem;">
                                                                    <button class="btn" @click="init">初始化</button>
                                                                    <button class="btn" @click="privewShow">发货单预览</button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="jerpCol" style="flex: 1;">
                                                            <div class="jerpRow">
                                                                <div>
                                                                    <span style="padding-left: 0.4rem;">{{supOrder.origin.sysStatus}}</span>
                                                                    <textarea disabled=true style="width: 20rem; height: 3rem; background: none; border: none;">{{supOrder.origin.memo}}</textarea>
                                                                </div>
                                                                <button class="btn" @click="submit(1)" style="width: 5rem;height: 3rem;font-size: 1.4rem;">提交</button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jerpCol">
                                                                        <span>产品：</span>
                                                                        <input type="text" style="width: 8rem;" :disabled='submitInfo.userId==""?true:false' v-model="selectOrderName" @keyup.enter="select"></input>
                                                                        <button class="btn" style="margin-left: 0.3rem;" :disabled='submitInfo.userId==""?true:false' @click="select">查询</button>
                                                                    </div>
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 4;">商品名称</div>
                                                                        <div class="jTable_col" style="flex: 1;">销售价</div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content" style="height: calc(100% - 5rem);">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in orderListsAddFlag">
                                                                            <div class="jTable_row" :class="{'noConsigned': !item.sysConsigned}" :style="{'background':item.isAdd?'#ffa9a9':''}" style="cursor:pointer;" @dblclick="addOrder(item)"> <!-- onselectstart="return false" -->
                                                                                <div class="jTable_col" style="flex: 4; white-space: normal;"><span :title="item.orderHot">{{item.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.priceOutput}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_footer min">
                                                                    <!--
                                                                        <div class="jerpRow >
                                                                            <div class="jerpCol">
                                                                                <div>共{{orderListsAddFlag.length}}条数据</div>
                                                                            </div>
                                                                        </div>
                                                                    -->
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol" style="margin-right: 1rem;">
                                                                            <div>
                                                                                <span>显示</span>
                                                                                <select v-model="jTable.left.footer.showTabNum">
                                                                                    <option value="0">全部</option>
                                                                                    <option value="50">50</option>
                                                                                    <option value="100">100</option>
                                                                                    <option value="200">200</option>
                                                                                    <option value="500">500</option>
                                                                                </select>
                                                                                <span>数据</span>
                                                                            </div>
                                                                        </div>
                                                                        <div class="jerpCol">
                                                                            <div class="jTable_footer_btn">
                                                                                <button :disabled="jTable.left.footer.nowTab<=1" @click="turnUpLeft"><</button>
                                                                            </div>
                                                                            <div>
                                                                                <span>第</span>
                                                                                <input type="rel" v-model="jTable.left.footer.nowTabInput" @change="tableTurnLeft"></input>
                                                                                <span>页/共{{jTable.left.footer.maxTab}}页</span>
                                                                            </div>
                                                                            <div class="jTable_footer_btn">
                                                                                <button :disabled="jTable.left.footer.nowTab>=jTable.left.footer.maxTab" @click="turnDownLeft">></button>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:3;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                        <div class="jTable_col" style="flex: 8;"><span>商品名称</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>系统销售价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>系统成本</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>采购价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>单价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>数量</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>总价</span></div>
                                                                        <!-- <div class="jTable_col" style="flex: 1;"><span>操作</span></div> -->
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row" style="cursor:pointer;">
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 8; white-space: normal;"><span>{{item.title}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{item.priceOutput}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{item.priceImport}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{newPurchasePrice(item)}}</span></div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" v-model="item.orderPrice" :class="{'error':item.priceImport>item.orderPrice}"></input>
                                                                                </div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" step="1" v-model="item.num"></input>
                                                                                </div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;"><span>{{orderTotalPrice(item)}}</span></div>
                                                                                <!-- 
                                                                                    <div class="jTable_col" style="flex: 1;">
                                                                                        <a class="iconfont icon-delete" @click="delOrder(index)"></a>
                                                                                    </div> 
                                                                                -->
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="cwt_info" style="flex-flow:column; margin-top: 0.3rem; margin-bottom: 0;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;" v-show="submitInfo.payType!=1">
                                                            <select v-model="payAccount"><!-- style="width: 8rem;" -->
                                                                <option v-for="item in payAccounts" :value="item.id">{{item.accountName}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>合计金额：{{totalPrice}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>合计数量：{{totalNum}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>重量：{{totalWeight}}kg</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>一共{{list.length}}种</span>
                                                        </div>
                                                        <!-- <div class="jerpRow" style="flex:1;margin-left: 3rem;">
                                                            <div class="jerpCol">
                                                                <input type="radio" name="pickGoodsType" value="2" v-model="submitInfo.pickGoodsType" :disabled='submitInfo.userId==""?true:false'>快递发货</input>
                                                                <input type="radio" name="pickGoodsType" value="1" v-model="submitInfo.pickGoodsType" :disabled='submitInfo.userId==""?true:false'>现场自提</input>
                                                            </div>
                                                        </div> -->
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" style="flex: 1;">
                                                            <span style="width: 6rem;">智能识别快递，输入地址：</span>
                                                            <textarea style="min-height: 6rem;max-width: 20.5rem;min-width: 20.5rem;" v-model="inputAdress" @keyup.enter="autoGetAddress"
                                                            :disabled='submitInfo.userId==""||submitInfo.pickGoodsType==1?true:false'></textarea>
                                                            <div class="jerpCol" style="display:flex;flex-flow:column;">
                                                                <button class="btn" @click="defaultAddress" 
                                                                :disabled='submitInfo.userId==""||submitInfo.pickGoodsType==1?true:false'
                                                                style="margin: 0 0 0.3rem 0.3rem;">默认地址</button>
                                                                <button class="btn" @click="autoGetAddress" 
                                                                :disabled='submitInfo.userId==""||submitInfo.pickGoodsType==1?true:false'>解析地址</button>
                                                            </div>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;display: flex;flex-flow: column;">
                                                            <div class="jerpRow">
                                                                <div class="jerpCol" style="margin-left: 2rem;flex: 1;">
                                                                    <div style="margin-left: 1rem;" v-for="item in flagList" >
                                                                        <input type="radio" :value="item.id" v-model="flag" :disabled='submitInfo.userId==""?true:false'></input>
                                                                        <span :class="item.class">{{item.title?item.title:''}}</span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpRow">
                                                                <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                    <textarea style="min-height:3rem;" placeholder='订单系统备注，如果不插旗，请选择"无"' v-model="memo" :disabled='submitInfo.userId==""?true:false'></textarea>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow" v-show="submitInfo.pickGoodsType==2?true:false">
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                            <!-- <span>快递：</span>
                                                            <select style="width: 8rem;" v-model="express" :disabled='submitInfo.userId==""?true:false'>
                                                                <option value="" disabled="true" selected="true">请选择快递</option>
                                                                <option v-for="item in expressList" :value="item.id">{{item.name}}</option>
                                                            </select> -->
                                                            <span style="width: 3.8rem;text-align: right;">姓名：</span>
                                                            <input type="text" v-model="pick2info.receiverName" :disabled='submitInfo.userId==""?true:false'/>
                                                            <span>手机号：</span>
                                                            <input type="text" v-model="pick2info.receiverMobile" :disabled='submitInfo.userId==""?true:false'/>
                                                            <span>省：</span>
                                                            <select v-model="pick2info.receiverState" :disabled='submitInfo.userId==""?true:false' style="width: 6rem;" @change="changeReceiver(1)">
                                                                <option v-for="(value, key) in province_filter" :value="key">{{key}}</option>
                                                            </select>
                                                            <span>市：</span>
                                                            <select v-model="pick2info.receiverCity" :disabled='submitInfo.userId==""?true:false' style="width: 6rem;" @change="changeReceiver(2)">
                                                                <option v-for="(value, key) in city_filter" :value="key">{{key}}</option>
                                                            </select>
                                                            <span>区：</span>
                                                            <select v-model="pick2info.receiverDistrict" :disabled='submitInfo.userId==""?true:false' style="width: 6rem;">
                                                                <option v-for="(value, key) in district_filter" :value="value">{{value}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow" v-show="submitInfo.pickGoodsType==2?true:false">
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                            <span>详细地址：</span>
                                                            <textarea style="min-height: 4rem;max-width: 51.3rem;" v-model="pick2info.receiverAddress" :disabled='submitInfo.userId==""?true:false'></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="jerpSubwin" 
                                            style="position:absolute; top:50%;left:50%;  margin: 0.5rem; width:60rem; z-index: 1000;
                                                background: white; border: 1px solid gray; border-radius: 0.5rem; box-shadow: 0 0 0.3rem;"
                                                :style="{transform: 'translate(calc(-50% + '+ priviewInfo.clientX +'px), calc(-50% + '+ priviewInfo.clientY +'px))'}"
                                                v-show='priviewInfo.priviewStatus'>
                                                <div class="btnFrame">
                                                    <a title="关闭" class="btn jerp_btn close" @click="privewClose()"><i>x</i></a>
                                                </div>
                                                <div id="priview" class="jerpSubwinTitle" @mousedown="priviewMouseDown">发货单预览</div><!-- @mousemove="priviewMouseMove" @mouseup="priviewMouseUp" -->
                                                <div class="jerpSubwinContent" style="width: calc(100% - 3rem); margin: 1.5rem;min-height: none; max-height: 50rem;">
                                                    <div class="jerpSubwinContent_inner" style="flex: 1;">
                                                        <div class="jerpRow" style="justify-content: center;">
                                                            <div class="jerpCol" style="flex:3;">
                                                                <div class="jerpRow" style="display:flex;">
                                                                    <div class="jerpCol" style="flex:1;">
                                                                        <span>{{priviewInfo.shortId}}<span>
                                                                    </div>
                                                                    <div class="jerpCol" style="flex:3; justify-content: center; font-size: 1.5rem;">
                                                                        <span>浙江若腾阀门有限公司</span>
                                                                    </div>
                                                                    <div class="jerpCol" style="flex:1;">
                                                                        <span><span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol"style="flex:3; display:flex;">
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>{{priviewInfo.pick2info.receiverState}}{{priviewInfo.pick2info.receiverCity}}{{priviewInfo.pick2info.receiverDistrict}}{{priviewInfo.pick2info.receiverAddress}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center; justify-content: center; font-size: 1.2rem;">
                                                                    <span>发货单</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center; flex-flow: column;">
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol">
                                                                            <span>打印时间：{{priviewInfo.printTime}}</span>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol">
                                                                            <span>开单时间：{{priviewInfo.printTime}}</span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol"style="flex:3; display:flex;">
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>客户：{{priviewInfo.pick2info.receiverName}}  {{priviewInfo.pick2info.receiverMobile}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>开单人：{{userName}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>备注：{{priviewInfo.remark}}</span>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="flex:3; display:flex;">
                                                                <div class="jTable" style="border: 1px solid #cfcfcf; border-bottom: none;">
                                                                    <div class="jTable_title" style="background: none;">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                            <div class="jTable_col" style="flex: 6;"><span>商品名称</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>数量</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>单价</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>总价</span></div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jTable_content">
                                                                        <div class="jTable_content_c">
                                                                            <div class="jTable_content_row" style="background: none;" v-for="(item,index) in priviewInfo.orders">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 6;"><span>{{item.title}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;"><span>{{item.num}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 3;"><span>{{item.orderPrice}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 3;"><span>{{orderTotalPrice(item)}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_content_row" style="background:none;">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 1;"><span>合计</span></div>
                                                                                    <div class="jTable_col" style="flex: 14; justify-content: normal;"><span>商品总数量：{{priviewTotalNum}}   商品总金额：{{priviewTotalPrice}}</span></span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div> 
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1; display:flex; margin: 0 0 1.8rem 3rem;">
                                                                <div class="jTable" style="border: 1px solid #cfcfcf; border-bottom: none;">
                                                                    <div class="jTable_title" style="background: none;">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>货位编码</span></div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jTable_content">
                                                                        <div class="jTable_content_c">
                                                                            <div class="jTable_content_row" style="background: none;" v-for="(item,index) in priviewInfo.orders">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 4;"><span>{{item.code}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div> 
                                                            </div> 
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "isReissue": false,
                                                    "isBlank": false,
                                                    "supOrder": { // 补单设置
                                                        "sid": "",
                                                        "supType": 0,
                                                        "supTypeList": [
                                                            // {
                                                            //     "name": "",
                                                            //     "blank": 0
                                                            // },
                                                            {
                                                                "name": "缺货",
                                                                "blank": 1
                                                            },
                                                            {
                                                                "name": "少发/漏发",
                                                                "blank": 1
                                                            },
                                                            {
                                                                "name": "错发",
                                                                "blank": 0
                                                            },
                                                            {
                                                                "name": "丢件",
                                                                "blank": 0
                                                            },
                                                            {
                                                                "name": "次品",
                                                                "blank": 0
                                                            },
                                                            {
                                                                "name": "快递异常",
                                                                "blank": 0
                                                            },
                                                            {
                                                                "name": "换货",
                                                                "blank": 0
                                                            }
                                                        ],
                                                        "origin": {
                                                            "sid": "",
                                                            "tid": "",
                                                            "shopFlag": "",
                                                            "shortId": "",
                                                            "memo": "",
                                                            "sysStatus": "",
                                                        }
                                                    },
                                                    "originOrderPick": "", // 原订单快递号
                                                    "SystemVersion": 1,
                                                    "orderHot": {}, // 商品热度，用于商品排序
                                                    "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    "distributor": '',// 分销商
                                                    "distributorList": [], // 分销商select-option
                                                    "commission": {}, // 分销价格
                                                    "showMore": false, // 显示更多
                                                    "selectOrderName": '', // 查询用产品名称
                                                    // ordersChache: [], // 所有商品缓存
                                                    "payAccount": '',
                                                    "payAccounts": [], // 支付账号
                                                    "orderLists": [], // 查询商品列表 priceOutput:销售, priceImport:成本
                                                    "flagList": [{
                                                        id: '',
                                                        class: '',
                                                        title: '无',
                                                    }, {
                                                        id: 0,
                                                        class: 'trade-icon-flag-0'
                                                    }, {
                                                        id: 1,
                                                        class: 'trade-icon-flag-1'
                                                    }, {
                                                        id: 2,
                                                        class: 'trade-icon-flag-2'
                                                    }, {
                                                        id: 3,
                                                        class: 'trade-icon-flag-3'
                                                    }, {
                                                        id: 4,
                                                        class: 'trade-icon-flag-4'
                                                    }, {
                                                        id: 5,
                                                        class: 'trade-icon-flag-5'
                                                    },
                                                        // {
                                                        //     id: 6,
                                                        //     class: 'trade-icon-flag-6'
                                                        // }, {
                                                        //     id: 7,
                                                        //     class: 'trade-icon-flag-7'
                                                        // }, {
                                                        //     id: 8,
                                                        //     class: 'trade-icon-flag-8'
                                                        // }, {
                                                        //     id: 9,
                                                        //     class: 'trade-icon-flag-9'
                                                        // }, {
                                                        //     id: 10,
                                                        //     class: 'trade-icon-flag-10'
                                                        // }
                                                    ],
                                                    "bindShopList": [],
                                                    "warehouse": "",
                                                    "warehouseList": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses,
                                                    flag: '', // 旗
                                                    memo: '', // 备注
                                                    "priviewInfo": {
                                                        sid: null,
                                                        shortId: null,
                                                        printTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                                                        orders: [],
                                                        pick2info: {},
                                                        priviewStatus: false,
                                                        clientX: 0,
                                                        clientY: 0,
                                                    },
                                                    inputAdress: '', // 智能获取快递信息
                                                    list: [], // 选中的商品列表
                                                    payFee: 0, // 收款金额
                                                    submitInfo: {
                                                        // "checkoutTime": new Date().getTime(),
                                                        "sid": "",
                                                        "id": "",
                                                        "stVersion": 2,
                                                        "outWarehouseId": "",
                                                        "retWarehouseId": "",
                                                        "origin": "PC",
                                                        "fileRemarks": ["", "", ""],
                                                        "settleType": 1, // 1： 提交  3： 挂起
                                                        "originSid": "",
                                                        "originId": "",
                                                        "cashType": 1,
                                                        "userId": 0, // 店铺id 900044135:线下（档口）
                                                        "submitterId": jerp.jerpSetting.currentUser,
                                                        // 以上不用动
                                                        remark: "", // 备注
                                                        customerId: "", // this.distributor.distributorCompanyId, // 分销上id
                                                        payType: "1", // 支付方式
                                                        pickGoodsType: 2, // 发货方式 1:自提 2:快递
                                                        surplusFee: 0, // 抹零
                                                        payInfos: [],
                                                        orders: [],
                                                    },
                                                    "express": "",
                                                    "expressList": [], // 快递
                                                    pick2info: {
                                                        "transportFee": 0, // 快递费
                                                        "templateId": "", // 极兔
                                                        "templateType": 0,
                                                        receiverName: "", // 收件人
                                                        receiverMobile: "", // 联系方式
                                                        receiverState: "", // 省
                                                        receiverCity: "", // 市
                                                        receiverDistrict: "", //区
                                                        receiverAddress: "", // 详细地址
                                                        receiverZip: "",
                                                        receiverPhone: "",
                                                    },
                                                    "jTable": {
                                                        "left": {
                                                            "footer": {
                                                                "showTabNum": 50,
                                                                "showTabList": [],
                                                                "nowTab": 1,
                                                                "nowTabInput": 1,
                                                                "maxTab": 0,
                                                            }
                                                        }
                                                    }
                                                },
                                                computed: {
                                                    province_filter: function () {
                                                        // console.log(jerp.jerpSetting.pca3level);
                                                        return jerp.jerpSetting.pca3level;
                                                    },
                                                    city_filter: function () {
                                                        if (this.pick2info.receiverState == "") {
                                                            return {};
                                                        } else {
                                                            return jerp.jerpSetting.pca3level[this.pick2info.receiverState];
                                                        }
                                                    },
                                                    district_filter: function () {
                                                        if (this.pick2info.receiverCity == "") {
                                                            return [];
                                                        } else {
                                                            return jerp.jerpSetting.pca3level[this.pick2info.receiverState][this.pick2info.receiverCity];
                                                        }
                                                    },
                                                    distributorZK: function () {
                                                        return jerp.math.chen(this.commission[this.distributor.distributorLevel].pp, 100)
                                                    },
                                                    distributorListSort: function () {
                                                        let self = this, list_xs = [], list_other = [];
                                                        for (let i = 0; i < self.distributorList.length; i++) {
                                                            let d = self.distributorList[i];
                                                            if (d.distributorCompanyName.includes('销售')) {
                                                                list_xs.push(d);
                                                            } else {
                                                                list_other.push(d);
                                                            }
                                                        }
                                                        return [...list_other, ...list_xs];
                                                    },
                                                    orderListsAddFlag: function () {
                                                        // let self = this, list = [];
                                                        // for (let i = 0; i < self.orderLists.length; i++) {
                                                        //     let o = self.orderLists[i];
                                                        //     list.push({
                                                        //         ...o,
                                                        //         ...{
                                                        //             isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                        //         }
                                                        //     })
                                                        // }
                                                        // // console.log(list);
                                                        // return list;

                                                        let self = this, showList = [],
                                                            showTabNum = this.jTable.left.footer.showTabNum;

                                                        this.jTable.left.footer.maxTab =
                                                            this.jTable.left.footer.showTabNum == 0 ? 1 : Math.ceil(self.orderLists.length / this.jTable.left.footer.showTabNum);
                                                        if (this.jTable.left.footer.nowTab > this.jTable.left.footer.maxTab) {
                                                            this.jTable.left.footer.nowTab = 1;
                                                            this.jTable.left.footer.nowTabInput = 1;
                                                        }
                                                        if (showTabNum == 0) {
                                                            for (let i = 0; i < self.orderLists.length; i++) {
                                                                let o = self.orderLists[i];
                                                                showList.push({
                                                                    ...o,
                                                                    ...{
                                                                        isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                                    }
                                                                })
                                                            }
                                                        } else {
                                                            for (let i = (this.jTable.left.footer.nowTab - 1) * showTabNum; i < this.jTable.left.footer.nowTab * showTabNum; i++) {
                                                                if (i >= self.orderLists.length) break;
                                                                let o = self.orderLists[i];
                                                                showList.push({
                                                                    ...o,
                                                                    ...{
                                                                        isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                                    }
                                                                })
                                                            }
                                                            return showList;
                                                        }
                                                    },
                                                    orderTotalPrice: function () {
                                                        return item => {
                                                            return item.orderPrice != "" && item.num != "" ? jerp.math.chen(item.orderPrice, item.num) : 0;
                                                        }
                                                    },
                                                    totalPrice: function () {
                                                        let totalPrice = 0;
                                                        this.list.map(v => {
                                                            if (v.orderPrice != "" && v.num != "") totalPrice = jerp.math.jia(totalPrice, this.orderTotalPrice(v));
                                                        });
                                                        this.payFee = jerp.math.jian(parseFloat(totalPrice), parseFloat(this.submitInfo.surplusFee));
                                                        // this.payFee = zs;
                                                        // this.submitInfo.surplusFee = jerp.math.jian(totalPrice, zs);
                                                        return totalPrice;
                                                    },
                                                    totalNum: function () {
                                                        let totalNum = 0;
                                                        this.list.map(v => {
                                                            if (v.num) totalNum = jerp.math.jia(totalNum, v.num);
                                                        });
                                                        return totalNum;
                                                    },
                                                    priviewTotalPrice: function () {
                                                        let totalPrice = 0;
                                                        this.priviewInfo.orders.map(v => {
                                                            if (v.orderPrice && v.num) totalPrice = jerp.math.jia(totalPrice, this.orderTotalPrice(v));
                                                        });
                                                        return totalPrice;
                                                    },
                                                    priviewTotalNum: function () {
                                                        let totalNum = 0;
                                                        this.priviewInfo.orders.map(v => {
                                                            if (v.num) totalNum = jerp.math.jia(totalNum, v.num);
                                                        });
                                                        return totalNum;
                                                    },
                                                    totalWeight: function () {
                                                        let totalWeight = 0;
                                                        this.list.map(v => {
                                                            if (v.weight && v.num) totalWeight = jerp.math.jia(totalWeight, jerp.math.chen(v.weight, v.num));
                                                        });
                                                        return totalWeight;
                                                    },
                                                    giveCount: function () { // 找零
                                                        return jerp.math.jian(jerp.math.jian(this.totalPrice, this.payFee ? this.payFee : 0), this.submitInfo.surplusFee ? this.submitInfo.surplusFee : 0);
                                                    },
                                                    newPurchasePrice: function () {
                                                        return (item) => {
                                                            // console.log(item.newPurchasePrice);
                                                            if (item.newPurchasePrice) {
                                                                // let ttPrice = jerp.math.chen(item.newPurchasePrice, this.commission[this.distributor.distributorLevel].pp);
                                                                // return item.newPurchasePrice + "\n 【" + ttPrice + "】";
                                                                return item.newPurchasePrice;
                                                            } else {
                                                                return '';
                                                            }
                                                        }
                                                    },
                                                },
                                                mounted: async function () {
                                                    let orderHotList = localStorage.getItem('orderHot');
                                                    // console.log('orderHotList: ', orderHotList, !orderHotList);
                                                    if (!orderHotList) this.orderHot = {}; else this.orderHot = JSON.parse(orderHotList)
                                                    // console.dir("orderHot: ", this.orderHot, typeof this.orderHot === 'object');
                                                    // 获取分销商
                                                    this.distributorList = await jerp.getData({
                                                        url: '/dms/queryDistributorPageList',
                                                        api_name: 'dms_queryDistributorPageList',
                                                        method: 'get',
                                                    }, {
                                                        requestState: 2,
                                                        permissionFilter: 1,
                                                        pageNo: 1,
                                                        pageSize: 50,
                                                    });
                                                    // console.log('分销商: ', this.distributorList);
                                                    // 获取分销商折扣
                                                    let commission = await jerp.getData({
                                                        url: '/dms/queryDefaultPriceRule',
                                                        api_name: 'dms_queryDefaultPriceRule',
                                                        method: 'get',
                                                        return: 'data'
                                                    }, {
                                                        pageNo: 1,
                                                        pageSize: 5
                                                    });
                                                    for (let i = 0; i < commission.customerPriceRules.length; i++) {
                                                        let c = commission.customerPriceRules[i];
                                                        this.commission[c.level] = {
                                                            pp: jerp.math.chu(c.distributorPriceParam, 100),
                                                            type: c.distributorPriceBase
                                                        };
                                                    }
                                                    // console.log('分销商折扣: ', this.commission);
                                                    // 获取收款方式
                                                    this.payTypeList = await jerp.getData({
                                                        url: '/fms/payTypeName/getPaymentTypeNameList',
                                                        api_name: 'fms_payTypeName_getPaymentTypeNameList',
                                                        method: 'get',
                                                        return: 'data',
                                                    }, {});
                                                    // console.log('收款方式: ', this.payTypeList);
                                                    // 获取收款账号
                                                    this.payAccounts = await jerp.getData({
                                                        url: '/fms/account/getPaymentAccountList',
                                                        api_name: 'fms_account_getPaymentAccountList',
                                                        method: 'get',
                                                        return: 'data',
                                                    }, {
                                                        pageNo: 1,
                                                        pageSize: 200,
                                                        enableStatus: 1,
                                                    });
                                                    // console.log('收款账号: ', this.payAccounts);
                                                    this.payAccount = this.payAccounts.length > 0 ? this.payAccounts[0].id : '';
                                                    /** 获取商品并存入缓存，因为要同时获取销售价，所以暂时不用这个方法
                                                    this.ordersChache = await jerp.getData({
                                                        url: '/item/query/simpleListV2',
                                                        api_name: 'item_query_simpleListV2',
                                                        method: 'get',
                                                    }, {pageNo: 1,});
                                                    */
                                                    // 

                                                    let bindShopList = [],
                                                        sysBindShop = jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].bindShops;
                                                    console.log(sysBindShop);
                                                    for (let i = 0; i < sysBindShop.length; i++) {
                                                        let sbind = sysBindShop[i];
                                                        // if (sbind.sourceName == "档口") {
                                                        // console.log(sbind);
                                                        bindShopList.push(sbind);
                                                        // }
                                                    }
                                                    this.bindShopList = bindShopList;
                                                    // if (bindShopList.length > 0) {
                                                    //     this.submitInfo.userId = this.bindShopList[0].userId;
                                                    // }
                                                    // for (let i = 0; i < this.bindShopList.length; i++) {
                                                    //     if (this.bindShopList[i].sourceName == "档口") {
                                                    //         this.submitInfo.userId = this.bindShopList[i].userId;
                                                    //         break;
                                                    //     }
                                                    // }
                                                    this.warehouse = this.warehouseList[0].id;

                                                    let expressList = [],
                                                        express = await jerp.getData({
                                                            url: '/pt/logistics/company/list',
                                                            api_name: 'pt_logistics_company_list',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                            receiptSource: "sale_trade",
                                                        });

                                                    if (express.length == 0) {
                                                        express = await jerp.getData({
                                                            url: '/pt/expresstemplate/groupbyexpresssid/get',
                                                            method: 'post',
                                                            return: 'data',
                                                        }, {
                                                            api_name: "pt_expresstemplate_groupbyexpresssid_get",
                                                            filterJitx: 0,
                                                            useLogisticsCompany: false
                                                        }, true);
                                                        for (let i = 0; i < express.expressTemplates.length; i++) {
                                                            let t = express.expressTemplates[i],
                                                                id = t.id.toString(),
                                                                name = t.name;
                                                            if (t.liveStatus == 1) {
                                                                // console.log(t);
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    // "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": t.templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        this.SystemVersion = 2;
                                                        for (let i = 0; i < express.length; i++) {
                                                            // console.log(express[i], express[i].templateVOList.length);
                                                            if (express[i].templateVOList.length > 0) {
                                                                let id = express[i].id.toString(),
                                                                    name = express[i].name;
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": express[i].templateVOList[0].templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.expressList = expressList;

                                                    this.init();

                                                    // console.log(this.distributor);
                                                    // console.log(this.commission);
                                                },
                                                methods: {
                                                    selectOriginOrder: async function () { // 通过原订单快递号查询订单数据
                                                        let self = this,
                                                            pickNum = this.originOrderPick;
                                                        if (pickNum == "") { jerp.pxmu.toast("请先输入快递单号！"); return; }
                                                        self.init();

                                                        let datas = await jerp.getData({
                                                            url: '/trade/search',
                                                            api_name: 'trade_search',
                                                            method: 'post',
                                                            return: "data.list"
                                                        }, {
                                                            useHasNext: 1,
                                                            _t: new Date().getTime(),
                                                            pageNo: 1,
                                                            outSid: pickNum,
                                                            dateTypeSelect: 0,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            queryType: 0,
                                                            queryId: 62,
                                                            pageSize: 50,
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                        });
                                                        // JT3125699370467
                                                        // console.log(datas);
                                                        if (datas.length > 0) {
                                                            let sid = datas[0].b;

                                                            let orders = await jerp.getData({
                                                                url: '/trade/search/sids',
                                                                api_name: 'trade_search_sids',
                                                                method: 'post',
                                                                return: "data.list"
                                                            }, {
                                                                useHasNext: 1,
                                                                _t: new Date().getTime(),
                                                                pageNo: 1,
                                                                outSid: pickNum,
                                                                dateTypeSelect: 0,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                key: "mainOuterId",
                                                                highlight: false,
                                                                queryType: 0,
                                                                field: "pay_time",
                                                                order: "desc",
                                                                pageSize: 10,
                                                                sids: sid,
                                                                withStock: true
                                                            });
                                                            // console.log(orders);
                                                            if (orders.length > 0) {

                                                                let data = orders[0],
                                                                    userInfo = {
                                                                        type: "",
                                                                        Id: "",
                                                                    };

                                                                self.supOrder.origin.sid = sid;
                                                                self.supOrder.origin.shopFlag = data.shopFlag != undefined ? data.shopFlag : 0;
                                                                self.supOrder.origin.shortId = data.shortId != undefined ? data.shortId : "";
                                                                self.supOrder.origin.memo = data.sellerMemo != undefined ? data.sellerMemo : "";
                                                                if (self.supOrder.origin.memo.includes("补发")) {
                                                                    jerp.pxmu.dialog("订单已存在补发，请确认后继续操作!")
                                                                }
                                                                self.supOrder.origin.sysStatus = data.originSysStatus != undefined ? jerp.sysStatus[data.originSysStatus] : "";

                                                                let b = [
                                                                    ...self.bindShopList.filter((e) => { return e.userId == data.userId }),
                                                                    ...self.bindShopList.filter((e) => { return e.title.includes("若腾") })
                                                                ];

                                                                // console.log(self.bindShopList.filter((e) => { return e.userId == data.userId }));
                                                                // console.log(self.bindShopList.filter((e) => { return e.title.includes("若腾") }));
                                                                if (b.length > 0) {
                                                                    self.submitInfo.userId = b[0].userId;
                                                                }

                                                                // 获取订单商品列表
                                                                // console.log(data.orders);
                                                                let dataFilter = [], i = 0;
                                                                data.orders.map((e) => {
                                                                    // if (e.sysConsigned) {
                                                                    if (e.suits != undefined && e.suits.length > 0) {
                                                                        e.suits.map(e2 => {
                                                                            let d = dataFilter.filter(v => { return v.outerId == e2.outerId });
                                                                            if (d.length > 0) {
                                                                                d[0].num = d[0].num + e.num;
                                                                            } else {
                                                                                dataFilter.push(e2);
                                                                            }
                                                                        })
                                                                    } else {
                                                                        let d = dataFilter.filter(v => { return v.outerId == e.outerId });
                                                                        if (d.length > 0) {
                                                                            d[0].num = d[0].num + e.num;
                                                                        } else {
                                                                            dataFilter.push(e);
                                                                        }
                                                                    }
                                                                    // }
                                                                });
                                                                self.orderLists = dataFilter.sort((a, b) => {
                                                                    let g1 = (a.goodsSectionCodes != undefined && a.goodsSectionCodes.length > 0) ?
                                                                        a.goodsSectionCodes[0] : jerp.getGoodsCodeByCache(a.sysOuterId, self.warehouse)[0];
                                                                    let g2 = (b.goodsSectionCodes != undefined && b.goodsSectionCodes.length > 0) ?
                                                                        b.goodsSectionCodes[0] : jerp.getGoodsCodeByCache(b.sysOuterId, self.warehouse)[0];
                                                                    if (g1 < g2) {
                                                                        return -1;
                                                                    }
                                                                    if (g1 > g2) {
                                                                        return 1;
                                                                    }
                                                                    return 0;
                                                                });
                                                                // console.log(self.orderLists);
                                                                // return;
                                                                // return;
                                                                // data.orders.map(e=>{
                                                                //     console.log(e.goodsSectionCodes[0]);
                                                                // })
                                                                // return;
                                                                self.supOrder.origin.tid = data.tid; //data.fxTid != undefined ? data.fxTid : data.tid;
                                                                let memoLeft = self.supOrder.supTypeList[self.supOrder.supType] != undefined ? self.supOrder.supTypeList[self.supOrder.supType].name : "";
                                                                self.memo = memoLeft + "补发：" + self.supOrder.origin.tid;
                                                                // return;
                                                                // 确认店铺类型
                                                                userInfo.type = data.shopSource;
                                                                userInfo.Id = data.taobaoId;
                                                                let tid = data.fxTid != undefined ? data.fxTid : data.tid;
                                                                let oaid = data.addressMd5;

                                                                // console.log("userInfo:", userInfo);
                                                                if (userInfo.Id != null) {
                                                                    switch (userInfo.type) {
                                                                        case "tb": {
                                                                            // 获取真实地址
                                                                            let platformIdDatas = await jerp.getData({
                                                                                url: '/trade/platformId',
                                                                                api_name: 'trade_platformId',
                                                                                method: 'post',
                                                                                return: "data"
                                                                            }, {
                                                                                sid: sid
                                                                            });
                                                                            if (platformIdDatas.data != undefined && platformIdDatas.data != null) {
                                                                                let platformId = platformIdDatas.data;

                                                                                // 淘宝第一次认证
                                                                                let auth1 = await jerp.getData({
                                                                                    url: '/trade/eco/token/auth',
                                                                                    api_name: 'trade_eco_token_auth',
                                                                                    method: 'post',
                                                                                    return: "data"
                                                                                }, {
                                                                                    userId: userInfo.Id,
                                                                                    isTopToken: false,
                                                                                    isGx: true,
                                                                                    tid: "",
                                                                                });
                                                                                if (auth1.sessionId != undefined) {
                                                                                    // let url = "https://eco-gw.alibaba.com/verify/getSecTokenByBX?";
                                                                                    // let index = 0;
                                                                                    // for (let key in auth1) {
                                                                                    //     url += key + "=" + auth1[key] + "&";
                                                                                    // }

                                                                                    $.ajax({
                                                                                        // url: url.slice(0, -1),
                                                                                        url: "https://eco-gw.alibaba.com/verify/getSecTokenByBX?" + jerp.jsonToUrlParam(auth1),
                                                                                        method: 'post',
                                                                                        dataType: 'json',
                                                                                        async: true,
                                                                                        success: async function (e) {
                                                                                            if (e != undefined) {
                                                                                                let model1 = e.model;

                                                                                                // 淘宝第二次认证
                                                                                                let auth2 = await jerp.getData({
                                                                                                    url: '/trade/eco/token/auth',
                                                                                                    api_name: 'trade_eco_token_auth',
                                                                                                    method: 'post',
                                                                                                    return: "data"
                                                                                                }, {
                                                                                                    userId: userInfo.Id,
                                                                                                    isTopToken: true,
                                                                                                    isGx: true,
                                                                                                    tid: platformId,
                                                                                                    secToken: model1,
                                                                                                });
                                                                                                if (auth2.sessionId != undefined) {
                                                                                                    await jerp.getData({
                                                                                                        url: '/trade/add/decrypt/log/to/kibana',
                                                                                                        api_name: 'trade_add_decrypt_log_to_kibana',
                                                                                                        method: 'post',
                                                                                                    }, {
                                                                                                        isGx: true,
                                                                                                        tid: platformId,
                                                                                                        userId: userInfo.Id,
                                                                                                        decryptType: 1,
                                                                                                    });

                                                                                                    // let url = "https://eco-gw.alibaba.com/verify/getSecTokenByBX?";
                                                                                                    // let index = 0;
                                                                                                    // for (let key in auth2) {
                                                                                                    //     url += key + "=" + auth1[key] + "&";
                                                                                                    // }

                                                                                                    $.ajax({
                                                                                                        // url: url.slice(0, -1),
                                                                                                        url: "https://eco-gw.alibaba.com/verify/getSecTokenByBX?" + jerp.jsonToUrlParam(auth2),
                                                                                                        method: 'post',
                                                                                                        dataType: 'json',
                                                                                                        async: true,
                                                                                                        success: async function (e) {
                                                                                                            if (e != undefined) {
                                                                                                                let model2 = e.model;
                                                                                                                // let url = "https://gw.api.taobao.com/router/rest?";
                                                                                                                let json = {
                                                                                                                    method: auth2['method'], // taobao.top.oaid.client.decrypt
                                                                                                                    app_key: auth2['topAppKey'], // 23204092
                                                                                                                    timestamp: auth2['time'], // 2025-07-10 10:24:53
                                                                                                                    v: "2.0",
                                                                                                                    top_once_token: auth2['topToken'], // arsys/gwam2YbnYICZtL6a4fs0X24Dsic4mzTrRJlKU
                                                                                                                    sign_method: "token",
                                                                                                                    sec_once_token: model2, // WpiFdJ5YYDZcb0Zad+JdE6Z
                                                                                                                    format: "json",
                                                                                                                    simplify: true,
                                                                                                                }

                                                                                                                $.ajax({
                                                                                                                    // url: url,
                                                                                                                    url: "https://gw.api.taobao.com/router/rest?" + jerp.jsonToUrlParam(json),
                                                                                                                    method: 'post',
                                                                                                                    dataType: 'json',
                                                                                                                    async: true,
                                                                                                                    data: {
                                                                                                                        query_list: JSON.stringify({ "tid": tid.split("-")[0], "oaid": oaid, "scene": 1006, "secret_no_days": 30 })
                                                                                                                    },
                                                                                                                    success: async function (e) {
                                                                                                                        // console.log(e);
                                                                                                                        if (e.receiver_list && e.receiver_list.length > 0) {
                                                                                                                            let r = e.receiver_list[0];

                                                                                                                            self.pick2info.receiverName = r.name;
                                                                                                                            self.pick2info.receiverMobile = r.mobile;
                                                                                                                            self.pick2info.receiverState = r.state;
                                                                                                                            self.pick2info.receiverCity = r.city;
                                                                                                                            self.pick2info.receiverDistrict = r.district;
                                                                                                                            self.pick2info.receiverAddress = r.address_detail;

                                                                                                                        }
                                                                                                                    }
                                                                                                                })
                                                                                                            }
                                                                                                        }
                                                                                                    })
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    })
                                                                                }
                                                                            }
                                                                            break;
                                                                        }
                                                                        case "sys":
                                                                        case "dangkou": {
                                                                            self.pick2info.receiverName = data.receiverName;
                                                                            self.pick2info.receiverMobile = data.receiverMobile;
                                                                            self.pick2info.receiverState = data.receiverState;
                                                                            self.pick2info.receiverCity = data.receiverCity;
                                                                            self.pick2info.receiverDistrict = data.receiverDistrict;
                                                                            self.pick2info.receiverAddress = data.receiverAddress;
                                                                            break;
                                                                        }
                                                                        default: {
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        } else {
                                                            jerp.pxmu.toast("未找到对应订单，请查询后重试！");
                                                        }
                                                    },
                                                    // changeBindShop: function () {},
                                                    // changeWarehouse: function () {
                                                    //     this.submitInfo.outWarehouseId
                                                    //     this.submitInfo.retWarehouseId
                                                    // },
                                                    turnUpLeft: function () {
                                                        this.jTable.left.footer.nowTabInput--;
                                                        this.tableTurnLeft();
                                                    },
                                                    turnDownLeft: function () {
                                                        this.jTable.left.footer.nowTabInput++;
                                                        this.tableTurnLeft();
                                                    },
                                                    tableTurnLeft: function () {
                                                        // let maxTab = this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(this.list.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.left.footer.nowTabInput < 1) {
                                                            this.jTable.left.footer.nowTabInput = 1;
                                                        }
                                                        if (this.jTable.left.footer.nowTabInput > this.jTable.left.footer.maxTab) {
                                                            this.jTable.left.footer.nowTabInput = this.jTable.left.footer.maxTab;
                                                        }
                                                        this.jTable.left.footer.nowTab = this.jTable.left.footer.nowTabInput;
                                                    },
                                                    changeReceiver: function (type) { // 三级联动变更
                                                        if (type === 1) {
                                                            this.pick2info.receiverCity = '';
                                                        }
                                                        if (type === 2) {
                                                            this.pick2info.receiverDistrict = '';
                                                        }
                                                        // console.log(type, this.pick2info.receiverState, this.pick2info.receiverCity, this.pick2info.receiverDistrict);
                                                    },
                                                    priviewMouseDown: function (e) {
                                                        let self = this, mouseX = parseFloat(e.clientX),
                                                            mouseY = parseFloat(e.clientY),
                                                            box = document.getElementById('priview');
                                                        document.onmousemove = function (e) {
                                                            let targetX = parseFloat(e.clientX),
                                                                targetY = parseFloat(e.clientY);
                                                            self.priviewInfo.clientX += targetX - mouseX;
                                                            self.priviewInfo.clientY += targetY - mouseY;
                                                            mouseX = targetX;
                                                            mouseY = targetY;
                                                        }
                                                        document.onmouseup = function () {
                                                            document.onmousemove = null;
                                                            box.onmouseup = null;
                                                        }
                                                    },
                                                    payFeeChange: function () {
                                                        // console.log('payFeeChange');
                                                        if (this.payFee > this.totalPrice) {
                                                            this.payFee = this.totalPrice;
                                                        }
                                                        if (this.payFee < 0 || this.payFee == "") {
                                                            this.payFee = 0;
                                                        }
                                                        // this.submitInfo.surplusFee = jerp.math.jian(this.totalPrice, this.payFee);
                                                    },
                                                    surplusFeeChange: function () {
                                                        // console.log('surplusFeeChange');
                                                        if (this.submitInfo.surplusFee > this.totalPrice) {
                                                            this.submitInfo.surplusFee = this.totalPrice;
                                                        }
                                                        if (this.submitInfo.surplusFee < 0 || this.submitInfo.surplusFee == "") {
                                                            this.submitInfo.surplusFee = 0;
                                                        }
                                                        // this.payFee = jerp.math.jian(this.totalPrice, this.submitInfo.surplusFee);
                                                    },
                                                    privewShow: function () {
                                                        this.priviewInfo.priviewStatus = true;
                                                    },
                                                    privewClose: function () {
                                                        this.priviewInfo.priviewStatus = false;
                                                    },
                                                    init: function () {
                                                        this.list = [];
                                                        this.orderLists = [];

                                                        this.payFee = 0; // 抹零金额
                                                        this.flag = '0';
                                                        this.submitInfo.remark = '';

                                                        if (this.isBlank) {
                                                            this.memo = '缺货补发：';
                                                        } else {
                                                            this.memo = '';
                                                        }
                                                        this.submitInfo.customerId = ""; // this.distributor.distributorCompanyId, // 分销上id
                                                        this.submitInfo.payType = this.submitInfo.payType ? this.submitInfo.payType : "1"; // 支付方式
                                                        this.submitInfo.pickGoodsType = this.submitInfo.pickGoodsType ? this.submitInfo.pickGoodsType : 2; // 发货方式 1:自提 2:快递
                                                        this.submitInfo.surplusFee = 0; // 抹零金额
                                                        this.submitInfo.payInfos = [];
                                                        this.submitInfo.orders = [];

                                                        this.pick2info.receiverName = "";
                                                        this.pick2info.receiverMobile = "";
                                                        this.pick2info.receiverState = "";
                                                        this.pick2info.receiverCity = "";
                                                        this.pick2info.receiverDistrict = "";
                                                        this.pick2info.receiverAddress = ""; // 详细地址
                                                        this.pick2info.receiverZip = "";
                                                        this.pick2info.receiverPhone = "";

                                                        this.inputAdress = '';

                                                        // this.supOrder = {
                                                        //     "sid": "",
                                                        //     "origin": {
                                                        //         "origin": {
                                                        //             "sid": "",
                                                        //             "shopFlag": "",
                                                        //             "shortId": "",
                                                        //             "memo": "",
                                                        //             "sysStatus": "",
                                                        //         }
                                                        //     }
                                                        // };

                                                        this.supOrder.sid = "";
                                                        this.supOrder.origin.sid = "";
                                                        this.supOrder.origin.shopFlag = "";
                                                        this.supOrder.origin.shortId = "";
                                                        this.supOrder.origin.memo = "";
                                                        this.supOrder.origin.sysStatus = "";
                                                    },
                                                    changeDistributor: function (e) {
                                                        let self = this;
                                                        if (e.target.value != "" && this.bindShopList.length > 0) {
                                                            this.distributor = this.distributorList.filter(v => { return v.id == e.target.value })[0];
                                                            let i = 0, ds = this.distributor.aliasName; // 别名
                                                            for (; i < this.bindShopList.length; i++) {
                                                                let b = this.bindShopList[i];
                                                                if (b.priorityTitle.includes(ds)) {
                                                                    this.submitInfo.userId = b.userId;
                                                                    break;
                                                                }
                                                            }
                                                            if (this.submitInfo.userId == "") {
                                                                this.submitInfo.userId = this.bindShopList[0].userId;
                                                            }
                                                        } else {
                                                            this.distributor = "";
                                                        }
                                                        this.list.map(v => {
                                                            v.orderPrice = jerp.math.chen((self.commission[self.distributor.distributorLevel].type == 0 ? v.priceOutput : v.priceImport), self.commission[self.distributor.distributorLevel].pp)
                                                        });
                                                        // this.init();
                                                        // this.inputAdress = '';
                                                        this.getDefaultAddress();
                                                    },
                                                    getDefaultAddress: async function () {
                                                        let address = await jerp.getData({
                                                            url: '/dms/address/get/defaultAddress',
                                                            api_name: 'dms_address_get_defaultAddress',
                                                            method: 'get',
                                                        }, {
                                                            distributorCompanyId: this.distributor.distributorCompanyId,
                                                        });
                                                        // console.log('address: ', address);
                                                        if (address.addressee != "") {
                                                            this.pick2info.receiverName = address.addressee ? address.addressee : '';
                                                            this.pick2info.receiverMobile = address.mobilePhone ? address.mobilePhone : '';
                                                            this.pick2info.receiverState = address.province ? address.province : '';
                                                            this.pick2info.receiverCity = address.city ? address.city : '';
                                                            this.pick2info.receiverDistrict = address.country ? address.country : '';
                                                            this.pick2info.receiverAddress = address.addr ? address.addr : '';
                                                        } else {
                                                            this.inputAdress = '若腾阀门 15868001780 浙江省温州市龙湾区滨海区丁香路新川工业园3幢5号4楼';
                                                        }
                                                    },
                                                    // 查找关键词对应的商品
                                                    select: async function () {
                                                        let self = this, adressOK = true;

                                                        /** 从缓存中获取数据，因为要同时获取销售价，所以暂时不用这个方法
                                                        let self = this;
                                                        let filter = this.selectOrderName.split(' ');
                                                        this.ordersChache.filter(v => {
                                                            let f = true;
                                                            for (let j = 0; j < filter.length; j++) {
                                                                if (!(v.title.indexOf(filter[j]) > -1)) {
                                                                    f = false;
                                                                    break;
                                                                }
                                                            }
                                                            if(f){
                                                                self.orderLists.push(v);
                                                            }
                                                        });
                                                         */
                                                        let orderName = this.selectOrderName;
                                                        if (orderName == "") { this.orderLists = []; return; }
                                                        let list = await jerp.getData({
                                                            // title: '',
                                                            url: '/item/list/all',
                                                            api_name: 'item_list_all',
                                                            method: 'post',
                                                        }, {
                                                            isAccurate: 0,
                                                            content: 'title',
                                                            text: orderName,
                                                            nameType: 1,
                                                            purchasePriceScope: 2,
                                                            specialFieldStatus: 2,
                                                            userId: -1,
                                                            companySourceType: 1,
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                        });
                                                        // console.log(JSON.parse(JSON.stringify(list)));
                                                        // console.log(self.orderHot);
                                                        // list.map(v => {
                                                        //     if (self.orderHot[v.outerId] === undefined) self.orderHot[v.outerId] = 0;
                                                        //     // console.log(self.orderHot[v.outerId]);
                                                        //     v.orderHot = parseInt(self.orderHot[v.outerId]);
                                                        //     v.sysConsigned = true;
                                                        // });
                                                        list = list.filter(v => {
                                                            let flag = false;
                                                            if (v.activeStatus == 1) {
                                                                flag = true;
                                                                if (self.orderHot[v.outerId] === undefined) self.orderHot[v.outerId] = 0;
                                                                // console.log(self.orderHot[v.outerId]);
                                                                v.orderHot = parseInt(self.orderHot[v.outerId]);
                                                                v.sysConsigned = true;
                                                            }
                                                            return flag;
                                                        })
                                                        this.orderLists = list.sort((a, b) => { return b.orderHot - a.orderHot });
                                                        // console.log(JSON.parse(JSON.stringify(this.orderLists)));
                                                    },
                                                    addOrder: async function (item) {
                                                        // console.log('item: ', item);
                                                        if (this.list.filter(v => { return v.outerId == item.outerId }).length > 0) return;
                                                        let self = this;

                                                        let goodsInfo = await jerp.getData({
                                                            url: '/item/v2/mini/list',
                                                            method: 'post',
                                                            return: 'data.list',
                                                        }, {
                                                            api_name: 'item_v2_mini_list',
                                                            needSuite: true,
                                                            withGoodsStock: true,
                                                            pageNo: 1,
                                                            pageSize: 50,
                                                            skuSizeSort: 1,
                                                            warehouseId: self.warehouse,
                                                            isAccurate: 1,
                                                            tileAllOuterId: item.outerId,
                                                            // tileSupplierId: ,
                                                            // supplierName: ,
                                                            source: 1,
                                                        });
                                                        // console.log('goodsInfo: ', goodsInfo);
                                                        if (goodsInfo.length > 0) {
                                                            let isblank = self.isReissue; // && self.supOrder.supTypeList[self.supOrder.supType].blank;

                                                            // 304 内内外三通 DN40
                                                            let g = goodsInfo[0],
                                                                supplierId = g.bestItemSupplierBridge != undefined ? g.bestItemSupplierBridge.supplierId : 0,
                                                                price = g.bestItemSupplierBridge != undefined ?
                                                                    (g.bestItemSupplierBridge.supplierPurchasePrice > 0 ? g.bestItemSupplierBridge.supplierPurchasePrice : g.purchasePrice)
                                                                    : g.purchasePrice != undefined ? g.purchasePrice : 0,
                                                                sysItemId = item.itemSysId != undefined ? item.itemSysId : item.sysItemId;
                                                            // console.log('supplierId: ', supplierId);
                                                            // console.log('price1:', price);
                                                            if (supplierId != 0) {
                                                                let queryLastPrice = await jerp.getData({
                                                                    url: '/caigou/purchase/queryLastPrice',
                                                                    method: 'post',
                                                                    return: 'data',
                                                                }, {
                                                                    "warehouseId": self.warehouse,
                                                                    "itemSysIds": [sysItemId],
                                                                    "skuSysIds": ["0"],
                                                                    "supplierIds": [supplierId.toString()]
                                                                }, true);
                                                                // console.log('queryLastPrice: ', queryLastPrice);
                                                                // queryLastPrice
                                                                for (let i in queryLastPrice) {
                                                                    if (queryLastPrice[i].purchasePrice != undefined) {
                                                                        price = queryLastPrice[i].purchasePrice;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            let codeList = await jerp.getGoodsCode(item.outerId, self.warehouse);
                                                            let codes = [];
                                                            if (codeList.length > 0) codeList.map(v => { codes.push(v.code) }); else codes.push('Z-Z-Z-Z-Z');
                                                            // console.log('price2:', price);
                                                            let priceOutput = !isblank ? (item.priceOutput != undefined ? item.priceOutput : (item.price != undefined ? item.price : 0)) : 0,
                                                                priceImport = !isblank ? (item.priceImport != undefined ? item.priceImport : (item.cost != undefined ? item.cost : 0)) : 0;
                                                            this.list.push({
                                                                itemSysId: sysItemId,
                                                                outerId: item.outerId,
                                                                title: item.title,
                                                                priceOutput: priceOutput,
                                                                priceImport: priceImport,
                                                                newPurchasePrice: jerp.math.chu(price != undefined ? price : 0, 100),
                                                                orderPrice: priceOutput, //jerp.math.chen((self.commission[self.distributor.distributorLevel].type == 0 ? priceOutput : priceImport), self.commission[self.distributor.distributorLevel].pp),
                                                                weight: item.weight,
                                                                code: codes.toString(),
                                                                // costPrice: costPrice,
                                                                num: (item.num != undefined && item.num > 0) ? item.num : 1,
                                                                picPath: item.picPath,
                                                            });
                                                        }
                                                        // setTimeout(async () => {
                                                        //     let v = this.list.filter(v => { return v.outerId == item.outerId })[0],
                                                        //         newPurchase = await jerp.getLastPurchaseOrder({ outerId: item.outerId, title: item.title }),
                                                        //         codeList = await jerp.getGoodsCode(item.outerId);
                                                        //     // console.log(newPurchase, newPurchase.purchasePrice, newPurchase ? newPurchase.purchasePrice : "");
                                                        //     v.newPurchasePrice = newPurchase ? newPurchase.purchasePrice : "";
                                                        //     // console.log(item.title + '_codeList: ', codeList);
                                                        //     let codes = [];
                                                        //     if (codeList.length > 0) codeList.map(v => { codes.push(v.code) }); else codes.push('Z-Z-Z-Z-Z');
                                                        //     v.code = codes.toString();
                                                        // }, 0);
                                                    },
                                                    delOrder: function (index) {
                                                        this.list.splice(index, 1);
                                                    },
                                                    defaultAddress: function () {
                                                        this.inputAdress = "若腾阀门 15868001708 浙江省温州市龙湾区滨海工业园区丁香路新川工业园3栋5号4楼";
                                                    },
                                                    autoGetAddress: async function () {
                                                        /** 数据结构
                                                        {
                                                            "api_name": "张三，13175661013，浙江省温州市龙湾区",
                                                            "clueId": "628926625282560519",
                                                            "data": {
                                                                "address": {
                                                                    "city": "温州市",
                                                                    "detail": "",
                                                                    "district": "龙湾区",
                                                                    "province": "浙江省",
                                                                    "str": "张三"
                                                                },
                                                                "guess": {
                                                                    "guessC": false,
                                                                    "guessD": false,
                                                                    "guesssP": false
                                                                },
                                                                "name": "张三",
                                                                "phone": "13175661013"
                                                            },
                                                            "qTime": 13,
                                                            "result": 1
                                                        }
                                                         */
                                                        let address = await jerp.getData({
                                                            url: '/trade/aiParseAddress',
                                                            api_name: 'trade_aiParseAddress',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            "rawAddress": this.inputAdress
                                                        });
                                                        // <span style="width: 3.8rem;text-align: right;">姓名：</span>
                                                        // <span>手机号：</span>
                                                        // <span>省：</span>
                                                        // <span>市：</span>
                                                        // <span>区：</span>
                                                        // <span>详细地址：</span>
                                                        this.pick2info.receiverName = address.name;
                                                        this.pick2info.receiverMobile = address.phone;
                                                        this.pick2info.receiverState = address.address.province;
                                                        this.pick2info.receiverCity = address.address.city;
                                                        this.pick2info.receiverDistrict = address.address.district;
                                                        this.pick2info.receiverAddress = address.address.detail;
                                                    },
                                                    submit: async function () {
                                                        let self = this,
                                                            addressOK = true;

                                                        if (self.pick2info.receiverAddress == "") { console.log("receiverAddress is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverName == "") { console.log("receiverName is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverMobile == "") { console.log("receiverMobile is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverState == "") { console.log("receiverState is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverCity == "") { console.log("receiverCity is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverDistrict == "") { console.log("receiverDistrict is blank"); addressOK = false; }
                                                        if (self.pick2info.receiverAddress == "") { console.log("receiverAddress is blank"); addressOK = false; }
                                                        // if (self.pick2info.receiverPhone == "") {console.log("receiverPhone is blank"); addressOK = false; }
                                                        if (!addressOK) {
                                                            jerp.pxmu.fail(`地址不能为空！补单请检查店铺！`);
                                                            return;
                                                        }

                                                        if (self.list.length == 0) {
                                                            jerp.pxmu.toast('请先选择商品');
                                                            return;
                                                        }

                                                        let saveData = {
                                                            force: true, // 库存不足也可以创建订单
                                                            buyerNick: "",
                                                            buyerTaxNo: "",
                                                            discountFee: "0",
                                                            expressCompanyId: "",
                                                            invoiceName: "",
                                                            isUrgent: 0,
                                                            logisticsCompanyId: "",

                                                            payment: self.totalPrice,
                                                            postFee: 0,
                                                            receiverAddress: self.pick2info.receiverAddress,
                                                            receiverCity: self.pick2info.receiverCity,
                                                            receiverDistrict: self.pick2info.receiverDistrict,
                                                            receiverMobile: self.pick2info.receiverMobile,
                                                            receiverName: self.pick2info.receiverName,
                                                            receiverPhone: self.pick2info.receiverPhone,
                                                            receiverState: self.pick2info.receiverState,
                                                            receiverZip: self.pick2info.receiverZip,
                                                            saleFee: 0,
                                                            sellerMemo: self.memo,
                                                            sysMemo: "",
                                                            taxFee: 0,
                                                            userId: self.submitInfo.userId,
                                                            warehouseId: self.warehouse,
                                                            warehouseName: jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses.filter((e) => { return e.id == self.warehouse })[0].name,
                                                        };
                                                        // console.log(self.list);
                                                        let orders = [];
                                                        for (let i = 0; i < self.list.length; i++) {
                                                            let l = self.list[i];
                                                            let o = {
                                                                ...l, ...{
                                                                    customGiftType: "0",
                                                                    discountFee: "0",
                                                                    discountRate: 0,
                                                                    isVirtual: "0",
                                                                    orderExt: { orderRemark: "" },
                                                                    outerSkuId: "",
                                                                    payment: jerp.math.chen(l.orderPrice, l.num),
                                                                    price: l.orderPrice,
                                                                    saleFee: 0,
                                                                    salePrice: 0,
                                                                    skuPropertiesName: "",
                                                                    skuSysId: "",
                                                                    totalFee: 0,
                                                                }
                                                            };
                                                            if (o.itemSysId == undefined || o.itemSysId == "") {
                                                                jerp.pxmu.toast(o.title + "没有itemSysId，请检查数据源");
                                                                return;
                                                            }
                                                            orders.push(o);
                                                        }
                                                        saveData.orders = orders;

                                                        let newOrder = await jerp.getData({
                                                            title: '单据创建中...',
                                                            url: '/trade/save',
                                                            method: 'post',
                                                            return: 'data.list',
                                                        }, saveData, true);
                                                        // console.log("newOrder: ", newOrder);
                                                        if (newOrder.length > 0) {
                                                            let n = newOrder[0],
                                                                shortId = n.shortId;

                                                            // 设置空单

                                                            if (self.supOrder.supTypeList[self.supOrder.supType].blank) {
                                                                let setBlank = await jerp.getData({
                                                                    url: '/trade/scalp',
                                                                    // api_name: 'trade_scalp',
                                                                    method: 'post',
                                                                    return: 'data',
                                                                }, {
                                                                    api_name: "trade_scalp",
                                                                    cancel: 0, // 设置空单
                                                                    sids: n.sid,
                                                                });

                                                                if (setBlank.status == "success") {
                                                                    // jerp.pxmu.closeload('空单已设置');
                                                                } else {
                                                                    jerp.pxmu.closeload('setBlank error:遇到错误，请联系管理员');
                                                                    jerp.sleep(1000);
                                                                }
                                                            }

                                                            // isReissue=true,向原单添加补发备注
                                                            if (self.isReissue && self.supOrder.origin.sid != "") {
                                                                let setFlag = await jerp.getData({
                                                                    url: '/trade/sellermemoflag/update',
                                                                    api_name: 'trade_sellermemoflag_update',
                                                                    method: 'post',
                                                                    return: 'data',
                                                                }, {
                                                                    memo: "补发：" + shortId + (self.supOrder.origin.memo != "" ? "；；；" + self.supOrder.origin.memo : ""),
                                                                    flag: self.supOrder.origin.shopFlag,
                                                                    sid: self.supOrder.origin.sid,
                                                                    memoType: 0, // 0:未解决 1:已解决
                                                                    notifyFx: true,
                                                                });

                                                                if (setFlag.status == "success") {
                                                                    // jerp.pxmu.closeload('备注完成');
                                                                } else {
                                                                    jerp.pxmu.closeload('setFlag error:遇到错误，请联系管理员');
                                                                    jerp.sleep(1000);
                                                                }
                                                            }

                                                            jerp.pxmu.copy(`${shortId},${self.supOrder.origin.shortId}`, "短号已复制");
                                                            // self.privewShow();
                                                            jerp.pxmu.closeload();
                                                            self.init();
                                                        }
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 档口系统
                                        name: '档口系统',
                                        subName: '线下',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特', '云淡风轻', '文员', "文员2"],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="flex-flow: column;">
                                                    <div class="jerpRow"> 
                                                        <div class="jerpCol">
                                                            <span>分销商：</span>
                                                            <select style="width: 8rem;" @change="changeDistributor">
                                                                <option value="" disabled="true" selected="true">请选择分销商</option>
                                                                <option v-for="item in distributorListSort" :value="item.id">{{item.distributorCompanyName}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                            <span>余额:{{distributor != '' ? distributor.balance : ''}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                            <span>等级：{{distributor != '' ? distributor.distributorLevel : ''}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                            <span>折扣：{{distributor != '' ? distributorZK + '%' : ''}}</span> <!-- (commission[distributor.distributorLevel].type == 0 ? '销售价' : '成本价') + ' x ' + -->
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>店铺：</span>
                                                            <select style="width: 8rem;" v-model="submitInfo.userId" :disabled='distributor==""?true:false'>
                                                                <option value="" disabled="true" selected="true">请选择店铺</option>
                                                                <option v-for="item in bindShopList" :value="item.userId">{{item.sourceName}}-{{item.priorityTitle}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <span>仓库：</span>
                                                            <select style="width: 8rem;" v-model="warehouse" :disabled='distributor==""?true:false'>
                                                                <option value="" disabled="true" selected="true">请选择仓库</option>
                                                                <option v-for="item in warehouseList" :value="item.id">{{item.name}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                            <input type="checkbox" v-model="showMore" style="margin: 0" :disabled='distributor==""?true:false'>显示更多</input>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                            <button class="btn" @click="init">初始化</button>
                                                            <button class="btn" @click="privewShow">发货单预览</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <div class="jerpRow">
                                                            <button class="btn" @click="submit(3)" style="width: 8rem;height: 3rem;font-size: 1.5rem;">挂起</button>
                                                            <button class="btn" @click="submit(1)" style="width: 8rem;height: 3rem;font-size: 1.5rem;">提交</button>
                                                        </div>
                                                        <!-- 补发不在使用档口建立
                                                            <div class="jerpRow">
                                                                <input type="checkbox" v-model="isBlank" :disabled='distributor==""?true:false'>补发</input>
                                                                <input type="text" v-model="originOrderPick" placeholder="输入原订单快递号" :disabled='isBlank==false?true:false'></input>
                                                                <button class="btn" @click="selectOriginOrder" :disabled='isBlank==false?true:false'>加载</button>
                                                            </div>
                                                        -->
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jerpCol">
                                                                        <span>产品：</span>
                                                                        <input type="text" style="width: 8rem;" :disabled='distributor==""?true:false' v-model="selectOrderName" @keyup.enter="select"></input>
                                                                        <button class="btn" style="margin-left: 0.3rem;" :disabled='distributor==""?true:false' @click="select">查询</button>
                                                                    </div>
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 4;">商品名称</div>
                                                                        <div class="jTable_col" style="flex: 1;">销售价</div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content" style="height: calc(100% - 5rem);">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in orderListsAddFlag">
                                                                            <div class="jTable_row" :style="{'background':item.isAdd?'#ffa9a9':''}" style="cursor:pointer;" @dblclick="addOrder(item)"> <!-- onselectstart="return false" -->
                                                                                <div class="jTable_col" style="flex: 4; white-space: normal;"><span :title="item.orderHot">{{item.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.priceOutput}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_footer min">
                                                                    <!--
                                                                        <div class="jerpRow >
                                                                            <div class="jerpCol">
                                                                                <div>共{{orderListsAddFlag.length}}条数据</div>
                                                                            </div>
                                                                        </div>
                                                                    -->
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol" style="margin-right: 1rem;">
                                                                            <div>
                                                                                <span>显示</span>
                                                                                <select v-model="jTable.left.footer.showTabNum">
                                                                                    <option value="0">全部</option>
                                                                                    <option value="50">50</option>
                                                                                    <option value="100">100</option>
                                                                                    <option value="200">200</option>
                                                                                    <option value="500">500</option>
                                                                                </select>
                                                                                <span>数据</span>
                                                                            </div>
                                                                        </div>
                                                                        <div class="jerpCol">
                                                                            <div class="jTable_footer_btn">
                                                                                <button :disabled="jTable.left.footer.nowTab<=1" @click="turnUpLeft"><</button>
                                                                            </div>
                                                                            <div>
                                                                                <span>第</span>
                                                                                <input type="rel" v-model="jTable.left.footer.nowTabInput" @change="tableTurnLeft"></input>
                                                                                <span>页/共{{jTable.left.footer.maxTab}}页</span>
                                                                            </div>
                                                                            <div class="jTable_footer_btn">
                                                                                <button :disabled="jTable.left.footer.nowTab>=jTable.left.footer.maxTab" @click="turnDownLeft">></button>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:3;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                        <div class="jTable_col" style="flex: 8;"><span>商品名称</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>系统销售价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>系统成本</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>采购价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>单价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>数量</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>总价</span></div>
                                                                        <!-- <div class="jTable_col" style="flex: 1;"><span>操作</span></div> -->
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row" style="cursor:pointer;">
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 8; white-space: normal;"><span>{{item.title}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{item.priceOutput}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{item.priceImport}}</span></div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;" v-show="showMore"><span>{{newPurchasePrice(item)}}</span></div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" v-model="item.orderPrice" :class="{'error':item.priceImport>item.orderPrice}"></input>
                                                                                </div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" step="1" v-model="item.num"></input>
                                                                                </div>
                                                                                <div class="jTable_col" @dblclick="delOrder(index)" style="flex: 4;"><span>{{orderTotalPrice(item)}}</span></div>
                                                                                <!-- 
                                                                                    <div class="jTable_col" style="flex: 1;">
                                                                                        <a class="iconfont icon-delete" @click="delOrder(index)"></a>
                                                                                    </div> 
                                                                                -->
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="cwt_info" style="flex-flow:column; margin-top: 0.3rem; margin-bottom: 0;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" style=" flex:2;">
                                                            <span style="width: 4.8rem;text-align: right;">付款方式：</span>
                                                            <input type="radio" :disabled='distributor==""?true:false' name="payType" v-model="submitInfo.payType" value="1">现金</input>
                                                            <input type="radio" :disabled='distributor==""?true:false' name="payType" v-model="submitInfo.payType" value="2">支付宝</input>
                                                            <input type="radio" :disabled='distributor==""?true:false' name="payType" v-model="submitInfo.payType" value="3">微信</input>
                                                            <input type="radio" :disabled='distributor==""?true:(distributor.balance>0?false:true)' name="payType" v-model="submitInfo.payType" value="5">余额</input>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;" v-show="submitInfo.payType!=1">
                                                            <select v-model="payAccount"><!-- style="width: 8rem;" -->
                                                                <option v-for="item in payAccounts" :value="item.id">{{item.accountName}}</option>
                                                            </select>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>合计金额：{{totalPrice}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>合计数量：{{totalNum}}</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>重量：{{totalWeight}}kg</span>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem; flex:1;">
                                                            <span>一共{{list.length}}种</span>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpRow" style="flex:5;">
                                                            <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                <span style="width: 3.8rem;text-align: right;">应付金额：</span><span>{{totalPrice}}</span>
                                                            </div>
                                                            <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                <span>收款：</span><input type="tel" step="0.0001" v-model="payFee" style="width:70%;":disabled='distributor==""?true:false'  @change="payFeeChange"></input>
                                                            </div>
                                                            <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                <span>抹零：</span><input type="tel" step="0.0001" v-model="submitInfo.surplusFee" style="width:70%;":disabled='distributor==""?true:false' @change="surplusFeeChange"></input>
                                                            </div>
                                                            <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                <span>未收金额：{{giveCount}}</span>
                                                            </div> 
                                                        </div>
                                                        <div class="jerpRow" style="flex:1;margin-left: 3rem;">
                                                            <div class="jerpCol">
                                                                <input type="radio" name="pickGoodsType" value="2" v-model="submitInfo.pickGoodsType" :disabled='distributor==""?true:false'>快递发货</input>
                                                                <input type="radio" name="pickGoodsType" value="1" v-model="submitInfo.pickGoodsType" :disabled='distributor==""?true:false'>现场自提</input>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow">
                                                        <div class="jerpCol" style="flex: 1;">
                                                            <span style="width: 6rem;">智能识别快递，输入地址：</span>
                                                            <textarea style="min-height: 6rem;max-width: 20.5rem;min-width: 20.5rem;" v-model="inputAdress" @keyup.enter="autoGetAddress"
                                                            :disabled='distributor==""||submitInfo.pickGoodsType==1?true:false'></textarea>
                                                            <div class="jerpCol" style="display:flex;flex-flow:column;">
                                                                <button class="btn" @click="defaultAddress" 
                                                                :disabled='distributor==""||submitInfo.pickGoodsType==1?true:false'
                                                                style="margin: 0 0 0.3rem 0.3rem;">默认地址</button>
                                                                <button class="btn" @click="autoGetAddress" 
                                                                :disabled='distributor==""||submitInfo.pickGoodsType==1?true:false'>解析地址</button>
                                                            </div>
                                                        </div>
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;display: flex;flex-flow: column;">
                                                            <div class="jerpRow">
                                                                <div class="jerpCol" style="margin-left: 2rem;flex: 1;">
                                                                    <div style="margin-left: 1rem;" v-for="item in flagList" >
                                                                        <input type="radio" :value="item.id" v-model="flag" :disabled='distributor==""?true:false'></input>
                                                                        <span :class="item.class">{{item.title?item.title:''}}</span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpRow">
                                                                <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                                    <textarea style="min-height:3rem;" placeholder='订单系统备注，如果不插旗，请选择"无"' v-model="memo" :disabled='distributor===""||flag===""?true:false'></textarea>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow" v-show="submitInfo.pickGoodsType==2?true:false">
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                            <span>快递：</span>
                                                            <select style="width: 8rem;" v-model="express" :disabled='distributor==""?true:false'>
                                                                <option value="" disabled="true" selected="true">请选择快递</option>
                                                                <option v-for="item in expressList" :value="item.id">{{item.name}}</option>
                                                            </select>
                                                            <span style="width: 3.8rem;text-align: right;">姓名：</span>
                                                            <input type="text" v-model="pick2info.receiverName" :disabled='distributor==""?true:false'/>
                                                            <span>手机号：</span>
                                                            <input type="text" v-model="pick2info.receiverMobile" :disabled='distributor==""?true:false'/>
                                                            <span>省：</span>
                                                            <select v-model="pick2info.receiverState" :disabled='distributor==""?true:false' style="width: 6rem;" @change="changeReceiver(1)">
                                                                <option v-for="(value, key) in province_filter" :value="key">{{key}}</option>
                                                            </select>
                                                            <span>市：</span>
                                                            <select v-model="pick2info.receiverCity" :disabled='distributor==""?true:false' style="width: 6rem;" @change="changeReceiver(2)">
                                                                <option v-for="(value, key) in city_filter" :value="key">{{key}}</option>
                                                            </select>
                                                            <span>区：</span>
                                                            <select v-model="pick2info.receiverDistrict" :disabled='distributor==""?true:false' style="width: 6rem;">
                                                                <option v-for="(value, key) in district_filter" :value="value">{{value}}</option>
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="jerpRow" v-show="submitInfo.pickGoodsType==2?true:false">
                                                        <div class="jerpCol" style="margin-left: 1rem;flex: 1;">
                                                            <span>详细地址：</span>
                                                            <textarea style="min-height: 4rem;max-width: 51.3rem;" v-model="pick2info.receiverAddress" :disabled='distributor==""?true:false'></textarea>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="jerpSubwin" 
                                            style="position:absolute; top:50%;left:50%;  margin: 0.5rem; width:60rem; z-index: 1000;
                                                background: white; border: 1px solid gray; border-radius: 0.5rem; box-shadow: 0 0 0.3rem;"
                                                :style="{transform: 'translate(calc(-50% + '+ priviewInfo.clientX +'px), calc(-50% + '+ priviewInfo.clientY +'px))'}"
                                                v-show='priviewInfo.priviewStatus'>
                                                <div class="btnFrame">
                                                    <a title="关闭" class="btn jerp_btn close" @click="privewClose()"><i>x</i></a>
                                                </div>
                                                <div id="priview" class="jerpSubwinTitle" @mousedown="priviewMouseDown">发货单预览</div><!-- @mousemove="priviewMouseMove" @mouseup="priviewMouseUp" -->
                                                <div class="jerpSubwinContent" style="width: calc(100% - 3rem); margin: 1.5rem;min-height: none; max-height: 50rem;">
                                                    <div class="jerpSubwinContent_inner" style="flex: 1;">
                                                        <div class="jerpRow" style="justify-content: center;">
                                                            <div class="jerpCol" style="flex:3;">
                                                                <div class="jerpRow" style="display:flex;">
                                                                    <div class="jerpCol" style="flex:1;">
                                                                        <span>{{priviewInfo.shortId}}<span>
                                                                    </div>
                                                                    <div class="jerpCol" style="flex:3; justify-content: center; font-size: 1.5rem;">
                                                                        <span>浙江若腾阀门有限公司</span>
                                                                    </div>
                                                                    <div class="jerpCol" style="flex:1;">
                                                                        <span><span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol"style="flex:3; display:flex;">
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>{{priviewInfo.pick2info.receiverState}}{{priviewInfo.pick2info.receiverCity}}{{priviewInfo.pick2info.receiverDistrict}}{{priviewInfo.pick2info.receiverAddress}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center; justify-content: center; font-size: 1.2rem;">
                                                                    <span>发货单</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center; flex-flow: column;">
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol">
                                                                            <span>打印时间：{{priviewInfo.printTime}}</span>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jerpRow">
                                                                        <div class="jerpCol">
                                                                            <span>开单时间：{{priviewInfo.printTime}}</span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol"style="flex:3; display:flex;">
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>客户：{{priviewInfo.pick2info.receiverName}}  {{priviewInfo.pick2info.receiverMobile}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>开单人：{{userName}}</span>
                                                                </div>
                                                                <div class="jerpCol" style="flex:1; align-items: center;">
                                                                    <span>备注：{{priviewInfo.remark}}</span>
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1;">
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol" style="flex:3; display:flex;">
                                                                <div class="jTable" style="border: 1px solid #cfcfcf; border-bottom: none;">
                                                                    <div class="jTable_title" style="background: none;">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                            <div class="jTable_col" style="flex: 6;"><span>商品名称</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>数量</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>单价</span></div>
                                                                            <div class="jTable_col" style="flex: 3;"><span>总价</span></div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jTable_content">
                                                                        <div class="jTable_content_c">
                                                                            <div class="jTable_content_row" style="background: none;" v-for="(item,index) in priviewInfo.orders">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 6;"><span>{{item.title}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 2;"><span>{{item.num}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 3;"><span>{{item.orderPrice}}</span></div>
                                                                                    <div class="jTable_col" style="flex: 3;"><span>{{orderTotalPrice(item)}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_content_row" style="background:none;">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 1;"><span>合计</span></div>
                                                                                    <div class="jTable_col" style="flex: 14; justify-content: normal;"><span>商品总数量：{{priviewTotalNum}}   商品总金额：{{priviewTotalPrice}}</span></span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div> 
                                                                </div>
                                                            </div>
                                                            <div class="jerpCol"style="flex:1; display:flex; margin: 0 0 1.8rem 3rem;">
                                                                <div class="jTable" style="border: 1px solid #cfcfcf; border-bottom: none;">
                                                                    <div class="jTable_title" style="background: none;">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>货位编码</span></div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="jTable_content">
                                                                        <div class="jTable_content_c">
                                                                            <div class="jTable_content_row" style="background: none;" v-for="(item,index) in priviewInfo.orders">
                                                                                <div class="jTable_row">
                                                                                    <div class="jTable_col" style="flex: 4;"><span>{{item.code}}</span></div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div> 
                                                                </div>
                                                            </div> 
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "isBlank": false,
                                                    "originOrderPick": "", // 原订单快递号
                                                    "SystemVersion": 1,
                                                    "orderHot": {}, // 商品热度，用于商品排序
                                                    "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    "distributor": '',// 分销商
                                                    "distributorList": [], // 分销商select-option
                                                    "commission": {}, // 分销价格
                                                    "showMore": false, // 显示更多
                                                    "selectOrderName": '', // 查询用产品名称
                                                    // ordersChache: [], // 所有商品缓存
                                                    "payAccount": '',
                                                    "payAccounts": [], // 支付账号
                                                    "orderLists": [], // 查询商品列表 priceOutput:销售, priceImport:成本
                                                    "flagList": [{
                                                        id: '',
                                                        class: '',
                                                        title: '无',
                                                    }, {
                                                        id: 0,
                                                        class: 'trade-icon-flag-0'
                                                    }, {
                                                        id: 1,
                                                        class: 'trade-icon-flag-1'
                                                    }, {
                                                        id: 2,
                                                        class: 'trade-icon-flag-2'
                                                    }, {
                                                        id: 3,
                                                        class: 'trade-icon-flag-3'
                                                    }, {
                                                        id: 4,
                                                        class: 'trade-icon-flag-4'
                                                    }, {
                                                        id: 5,
                                                        class: 'trade-icon-flag-5'
                                                    },
                                                        // {
                                                        //     id: 6,
                                                        //     class: 'trade-icon-flag-6'
                                                        // }, {
                                                        //     id: 7,
                                                        //     class: 'trade-icon-flag-7'
                                                        // }, {
                                                        //     id: 8,
                                                        //     class: 'trade-icon-flag-8'
                                                        // }, {
                                                        //     id: 9,
                                                        //     class: 'trade-icon-flag-9'
                                                        // }, {
                                                        //     id: 10,
                                                        //     class: 'trade-icon-flag-10'
                                                        // }
                                                    ],
                                                    "bindShopList": [],
                                                    "warehouse": "",
                                                    "warehouseList": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].warehouses,
                                                    flag: '', // 旗
                                                    memo: '', // 备注
                                                    "priviewInfo": {
                                                        sid: null,
                                                        shortId: null,
                                                        printTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                                                        orders: [],
                                                        pick2info: {},
                                                        priviewStatus: false,
                                                        clientX: 0,
                                                        clientY: 0,
                                                    },
                                                    inputAdress: '', // 智能获取快递信息
                                                    list: [], // 选中的商品列表
                                                    payFee: 0, // 收款金额
                                                    submitInfo: {
                                                        // "checkoutTime": new Date().getTime(),
                                                        "sid": "",
                                                        "id": "",
                                                        "stVersion": 2,
                                                        "outWarehouseId": "",
                                                        "retWarehouseId": "",
                                                        "origin": "PC",
                                                        "fileRemarks": ["", "", ""],
                                                        "settleType": 1, // 1： 提交  3： 挂起
                                                        "originSid": "",
                                                        "originId": "",
                                                        "cashType": 1,
                                                        "userId": 0, // 店铺id 900044135:线下（档口）
                                                        "submitterId": jerp.jerpSetting.currentUser,
                                                        // 以上不用动
                                                        remark: "", // 备注
                                                        customerId: "", // this.distributor.distributorCompanyId, // 分销上id
                                                        payType: "1", // 支付方式
                                                        pickGoodsType: 2, // 发货方式 1:自提 2:快递
                                                        surplusFee: 0, // 抹零
                                                        payInfos: [],
                                                        orders: [],
                                                    },
                                                    "express": "",
                                                    "expressList": [], // 快递
                                                    pick2info: {
                                                        "transportFee": 0, // 快递费
                                                        "templateId": "", // 极兔
                                                        "templateType": 0,
                                                        receiverName: "", // 收件人
                                                        receiverMobile: "", // 联系方式
                                                        receiverState: "", // 省
                                                        receiverCity: "", // 市
                                                        receiverDistrict: "", //区
                                                        receiverAddress: "", // 详细地址
                                                        receiverZip: "",
                                                        receiverPhone: "",
                                                    },
                                                    "jTable": {
                                                        "left": {
                                                            "footer": {
                                                                "showTabNum": 50,
                                                                "showTabList": [],
                                                                "nowTab": 1,
                                                                "nowTabInput": 1,
                                                                "maxTab": 0,
                                                            }
                                                        }
                                                    }
                                                },
                                                computed: {
                                                    province_filter: function () {
                                                        // console.log(jerp.jerpSetting.pca3level);
                                                        return jerp.jerpSetting.pca3level;
                                                    },
                                                    city_filter: function () {
                                                        if (this.pick2info.receiverState == "") {
                                                            return {};
                                                        } else {
                                                            return jerp.jerpSetting.pca3level[this.pick2info.receiverState];
                                                        }
                                                    },
                                                    district_filter: function () {
                                                        if (this.pick2info.receiverCity == "") {
                                                            return [];
                                                        } else {
                                                            return jerp.jerpSetting.pca3level[this.pick2info.receiverState][this.pick2info.receiverCity];
                                                        }
                                                    },
                                                    distributorZK: function () {
                                                        return jerp.math.chen(this.commission[this.distributor.distributorLevel].pp, 100)
                                                    },
                                                    distributorListSort: function () {
                                                        let self = this, list_xs = [], list_other = [];
                                                        for (let i = 0; i < self.distributorList.length; i++) {
                                                            let d = self.distributorList[i];
                                                            if (d.distributorCompanyName.includes('销售')) {
                                                                list_xs.push(d);
                                                            } else {
                                                                list_other.push(d);
                                                            }
                                                        }
                                                        return [...list_other, ...list_xs];
                                                    },
                                                    orderListsAddFlag: function () {
                                                        // let self = this, list = [];
                                                        // for (let i = 0; i < self.orderLists.length; i++) {
                                                        //     let o = self.orderLists[i];
                                                        //     list.push({
                                                        //         ...o,
                                                        //         ...{
                                                        //             isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                        //         }
                                                        //     })
                                                        // }
                                                        // // console.log(list);
                                                        // return list;

                                                        let self = this, showList = [],
                                                            showTabNum = this.jTable.left.footer.showTabNum;

                                                        this.jTable.left.footer.maxTab =
                                                            this.jTable.left.footer.showTabNum == 0 ? 1 : Math.ceil(self.orderLists.length / this.jTable.left.footer.showTabNum);
                                                        if (this.jTable.left.footer.nowTab > this.jTable.left.footer.maxTab) {
                                                            this.jTable.left.footer.nowTab = 1;
                                                            this.jTable.left.footer.nowTabInput = 1;
                                                        }
                                                        if (showTabNum == 0) {
                                                            for (let i = 0; i < self.orderLists.length; i++) {
                                                                let o = self.orderLists[i];
                                                                showList.push({
                                                                    ...o,
                                                                    ...{
                                                                        isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                                    }
                                                                })
                                                            }
                                                        } else {
                                                            for (let i = (this.jTable.left.footer.nowTab - 1) * showTabNum; i < this.jTable.left.footer.nowTab * showTabNum; i++) {
                                                                if (i >= self.orderLists.length) break;
                                                                let o = self.orderLists[i];
                                                                showList.push({
                                                                    ...o,
                                                                    ...{
                                                                        isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                                    }
                                                                })
                                                            }
                                                            return showList;
                                                        }
                                                    },
                                                    orderTotalPrice: function () {
                                                        return item => {
                                                            return item.orderPrice != "" && item.num != "" ? jerp.math.chen(item.orderPrice, item.num) : 0;
                                                        }
                                                    },
                                                    totalPrice: function () {
                                                        let totalPrice = 0;
                                                        this.list.map(v => {
                                                            if (v.orderPrice != "" && v.num != "") totalPrice = jerp.math.jia(totalPrice, this.orderTotalPrice(v));
                                                        });
                                                        this.payFee = jerp.math.jian(parseFloat(totalPrice), parseFloat(this.submitInfo.surplusFee));
                                                        // this.payFee = zs;
                                                        // this.submitInfo.surplusFee = jerp.math.jian(totalPrice, zs);
                                                        return totalPrice;
                                                    },
                                                    totalNum: function () {
                                                        let totalNum = 0;
                                                        this.list.map(v => {
                                                            if (v.num) totalNum = jerp.math.jia(totalNum, v.num);
                                                        });
                                                        return totalNum;
                                                    },
                                                    priviewTotalPrice: function () {
                                                        let totalPrice = 0;
                                                        this.priviewInfo.orders.map(v => {
                                                            if (v.orderPrice && v.num) totalPrice = jerp.math.jia(totalPrice, this.orderTotalPrice(v));
                                                        });
                                                        return totalPrice;
                                                    },
                                                    priviewTotalNum: function () {
                                                        let totalNum = 0;
                                                        this.priviewInfo.orders.map(v => {
                                                            if (v.num) totalNum = jerp.math.jia(totalNum, v.num);
                                                        });
                                                        return totalNum;
                                                    },
                                                    totalWeight: function () {
                                                        let totalWeight = 0;
                                                        this.list.map(v => {
                                                            if (v.weight && v.num) totalWeight = jerp.math.jia(totalWeight, jerp.math.chen(v.weight, v.num));
                                                        });
                                                        return totalWeight;
                                                    },
                                                    giveCount: function () { // 找零
                                                        return jerp.math.jian(jerp.math.jian(this.totalPrice, this.payFee ? this.payFee : 0), this.submitInfo.surplusFee ? this.submitInfo.surplusFee : 0);
                                                    },
                                                    newPurchasePrice: function () {
                                                        return (item) => {
                                                            // console.log(item.newPurchasePrice);
                                                            if (item.newPurchasePrice) {
                                                                let ttPrice = jerp.math.chen(item.newPurchasePrice, this.commission[this.distributor.distributorLevel].pp);
                                                                return item.newPurchasePrice + "\n 【" + ttPrice + "】";
                                                            } else {
                                                                return '';
                                                            }
                                                        }
                                                    },
                                                },
                                                mounted: async function () {
                                                    let orderHotList = localStorage.getItem('orderHot');
                                                    // console.log('orderHotList: ', orderHotList, !orderHotList);
                                                    if (!orderHotList) this.orderHot = {}; else this.orderHot = JSON.parse(orderHotList)
                                                    // console.dir("orderHot: ", this.orderHot, typeof this.orderHot === 'object');
                                                    // 获取分销商
                                                    this.distributorList = await jerp.getData({
                                                        url: '/dms/queryDistributorPageList',
                                                        api_name: 'dms_queryDistributorPageList',
                                                        method: 'get',
                                                    }, {
                                                        requestState: 2,
                                                        permissionFilter: 1,
                                                        pageNo: 1,
                                                        pageSize: 50,
                                                    });
                                                    // console.log('分销商: ', this.distributorList);
                                                    // 获取分销商折扣
                                                    let commission = await jerp.getData({
                                                        url: '/dms/queryDefaultPriceRule',
                                                        api_name: 'dms_queryDefaultPriceRule',
                                                        method: 'get',
                                                        return: 'data'
                                                    }, {
                                                        pageNo: 1,
                                                        pageSize: 5
                                                    });
                                                    for (let i = 0; i < commission.customerPriceRules.length; i++) {
                                                        let c = commission.customerPriceRules[i];
                                                        this.commission[c.level] = {
                                                            pp: jerp.math.chu(c.distributorPriceParam, 100),
                                                            type: c.distributorPriceBase
                                                        };
                                                    }
                                                    // console.log('分销商折扣: ', this.commission);
                                                    // 获取收款方式
                                                    this.payTypeList = await jerp.getData({
                                                        url: '/fms/payTypeName/getPaymentTypeNameList',
                                                        api_name: 'fms_payTypeName_getPaymentTypeNameList',
                                                        method: 'get',
                                                        return: 'data',
                                                    }, {});
                                                    // console.log('收款方式: ', this.payTypeList);
                                                    // 获取收款账号
                                                    this.payAccounts = await jerp.getData({
                                                        url: '/fms/account/getPaymentAccountList',
                                                        api_name: 'fms_account_getPaymentAccountList',
                                                        method: 'get',
                                                        return: 'data',
                                                    }, {
                                                        pageNo: 1,
                                                        pageSize: 200,
                                                        enableStatus: 1,
                                                    });
                                                    // console.log('收款账号: ', this.payAccounts);
                                                    this.payAccount = this.payAccounts.length > 0 ? this.payAccounts[0].id : '';
                                                    /** 获取商品并存入缓存，因为要同时获取销售价，所以暂时不用这个方法
                                                    this.ordersChache = await jerp.getData({
                                                        url: '/item/query/simpleListV2',
                                                        api_name: 'item_query_simpleListV2',
                                                        method: 'get',
                                                    }, {pageNo: 1,});
                                                    */
                                                    // 

                                                    let bindShopList = [],
                                                        sysBindShop = jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].bindShops;
                                                    for (let i = 0; i < sysBindShop.length; i++) {
                                                        let sbind = sysBindShop[i];
                                                        if (sbind.sourceName == "档口") {
                                                            // console.log(sbind);
                                                            bindShopList.push(sbind);
                                                        }
                                                    }
                                                    this.bindShopList = bindShopList;
                                                    // if (bindShopList.length > 0) {
                                                    //     this.submitInfo.userId = this.bindShopList[0].userId;
                                                    // }
                                                    // for (let i = 0; i < this.bindShopList.length; i++) {
                                                    //     if (this.bindShopList[i].sourceName == "档口") {
                                                    //         this.submitInfo.userId = this.bindShopList[i].userId;
                                                    //         break;
                                                    //     }
                                                    // }
                                                    this.warehouse = this.warehouseList[0].id;

                                                    let expressList = [],
                                                        express = await jerp.getData({
                                                            url: '/pt/logistics/company/list',
                                                            api_name: 'pt_logistics_company_list',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                            receiptSource: "sale_trade",
                                                        });

                                                    if (express.length == 0) {
                                                        express = await jerp.getData({
                                                            url: '/pt/expresstemplate/groupbyexpresssid/get',
                                                            method: 'post',
                                                            return: 'data',
                                                        }, {
                                                            api_name: "pt_expresstemplate_groupbyexpresssid_get",
                                                            filterJitx: 0,
                                                            useLogisticsCompany: false
                                                        }, true);
                                                        for (let i = 0; i < express.expressTemplates.length; i++) {
                                                            let t = express.expressTemplates[i],
                                                                id = t.id.toString(),
                                                                name = t.name;
                                                            if (t.liveStatus == 1) {
                                                                // console.log(t);
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    // "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": t.templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        this.SystemVersion = 2;
                                                        for (let i = 0; i < express.length; i++) {
                                                            // console.log(express[i], express[i].templateVOList.length);
                                                            if (express[i].templateVOList.length > 0) {
                                                                let id = express[i].id.toString(),
                                                                    name = express[i].name;
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": express[i].templateVOList[0].templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.expressList = expressList;

                                                    this.init();
                                                },
                                                methods: {
                                                    selectOriginOrder: async function () { // 通过原订单快递号查询订单数据
                                                        return;
                                                        let self = this,
                                                            pickNum = this.originOrderPick;
                                                        if (pickNum == "") { jerp.pxmu.toast("请先输入快递单号！"); return; }
                                                        let datas = await jerp.getData({
                                                            url: '/trade/search',
                                                            api_name: 'trade_search',
                                                            method: 'post',
                                                            return: "data.list"
                                                        }, {
                                                            useHasNext: 1,
                                                            _t: new Date().getTime(),
                                                            pageNo: 1,
                                                            outSid: pickNum,
                                                            dateTypeSelect: 0,
                                                            minutesAfterPaidOrderAreNotDisplayed: 0,
                                                            queryType: 0,
                                                            queryId: 62,
                                                            pageSize: 50,
                                                            needOrder: 0,
                                                            useCompress: 1,
                                                        });
                                                        // JT3125699370467
                                                        // console.log(datas);
                                                        if (datas.length > 0) {
                                                            let sid = datas[0].b;
                                                            let orders = await jerp.getData({
                                                                url: '/trade/search/sids',
                                                                api_name: 'trade_search_sids',
                                                                method: 'post',
                                                                return: "data.list"
                                                            }, {
                                                                useHasNext: 1,
                                                                _t: new Date().getTime(),
                                                                pageNo: 1,
                                                                outSid: pickNum,
                                                                dateTypeSelect: 0,
                                                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                                                key: "mainOuterId",
                                                                highlight: false,
                                                                queryType: 0,
                                                                field: "pay_time",
                                                                order: "desc",
                                                                pageSize: 10,
                                                                sids: sid,
                                                                withStock: true
                                                            });
                                                            // console.log(orders);
                                                            if (orders.length > 0) {

                                                                let data = orders[0],
                                                                    userInfo = {
                                                                        type: "",
                                                                        Id: "",
                                                                    };

                                                                // 获取订单商品列表
                                                                self.orderLists = data.orders;
                                                                self.memo = "缺货补发：" + (data.fxTid != undefined ? data.fxTid : data.tid);
                                                                // return;
                                                                // 确认店铺类型
                                                                // console.log("data: ", data);
                                                                if (data.taobaoId != undefined) {
                                                                    userInfo.type = "taobao";
                                                                    userInfo.Id = data.taobaoId;
                                                                } else {

                                                                }
                                                                // console.log("userInfo:", userInfo);
                                                                if (userInfo.Id != null) {
                                                                    switch (userInfo.type) {
                                                                        case "taobao": {
                                                                            // 获取真实地址
                                                                            let platformIdDatas = await jerp.getData({
                                                                                url: '/trade/platformId',
                                                                                api_name: 'trade_platformId',
                                                                                method: 'post',
                                                                                return: "data"
                                                                            }, {
                                                                                sid: sid
                                                                            });
                                                                            if (platformIdDatas.data != undefined && platformIdDatas.data != null) {
                                                                                let platformId = platformIdDatas.data;

                                                                                // 淘宝第一次认证
                                                                                let auth1 = await jerp.getData({
                                                                                    url: '/trade/eco/token/auth',
                                                                                    api_name: 'trade_eco_token_auth',
                                                                                    method: 'post',
                                                                                    return: "data"
                                                                                }, {
                                                                                    userId: userInfo.Id,
                                                                                    isTopToken: false,
                                                                                    isGx: true,
                                                                                    tid: "",
                                                                                });
                                                                                if (auth1.sessionId != undefined) {
                                                                                    // let url = "https://eco-gw.alibaba.com/verify/getSecTokenByBX?";
                                                                                    // let index = 0;
                                                                                    // for (let key in auth1) {
                                                                                    //     url += key + "=" + auth1[key] + "&";
                                                                                    // }

                                                                                    $.ajax({
                                                                                        // url: url.slice(0, -1),
                                                                                        url: "https://eco-gw.alibaba.com/verify/getSecTokenByBX?" + jerp.jsonToUrlParam(auth1),
                                                                                        method: 'post',
                                                                                        dataType: 'json',
                                                                                        async: true,
                                                                                        success: async function (e) {
                                                                                            if (e != undefined) {
                                                                                                let model1 = e.model;

                                                                                                // 淘宝第二次认证
                                                                                                let auth2 = await jerp.getData({
                                                                                                    url: '/trade/eco/token/auth',
                                                                                                    api_name: 'trade_eco_token_auth',
                                                                                                    method: 'post',
                                                                                                    return: "data"
                                                                                                }, {
                                                                                                    userId: userInfo.Id,
                                                                                                    isTopToken: true,
                                                                                                    isGx: true,
                                                                                                    tid: platformId,
                                                                                                    secToken: model1,
                                                                                                });
                                                                                                if (auth2.sessionId != undefined) {
                                                                                                    await jerp.getData({
                                                                                                        url: '/trade/add/decrypt/log/to/kibana',
                                                                                                        api_name: 'trade_add_decrypt_log_to_kibana',
                                                                                                        method: 'post',
                                                                                                    }, {
                                                                                                        isGx: true,
                                                                                                        tid: platformId,
                                                                                                        userId: userInfo.Id,
                                                                                                        decryptType: 1,
                                                                                                    });

                                                                                                    // let url = "https://eco-gw.alibaba.com/verify/getSecTokenByBX?";
                                                                                                    // let index = 0;
                                                                                                    // for (let key in auth2) {
                                                                                                    //     url += key + "=" + auth1[key] + "&";
                                                                                                    // }

                                                                                                    $.ajax({
                                                                                                        // url: url.slice(0, -1),
                                                                                                        url: "https://eco-gw.alibaba.com/verify/getSecTokenByBX?" + jerp.jsonToUrlParam(auth2),
                                                                                                        method: 'post',
                                                                                                        dataType: 'json',
                                                                                                        async: true,
                                                                                                        success: async function (e) {
                                                                                                            if (e != undefined) {
                                                                                                                let model2 = e.model;
                                                                                                                // let url = "https://gw.api.taobao.com/router/rest?";
                                                                                                                let json = {
                                                                                                                    method: auth2['method'], // taobao.top.oaid.client.decrypt
                                                                                                                    app_key: auth2['topAppKey'], // 23204092
                                                                                                                    timestamp: auth2['time'], // 2025-07-10 10:24:53
                                                                                                                    v: "2.0",
                                                                                                                    top_once_token: auth2['topToken'], // arsys/gwam2YbnYICZtL6a4fs0X24Dsic4mzTrRJlKU
                                                                                                                    sign_method: "token",
                                                                                                                    sec_once_token: model2, // WpiFdJ5YYDZcb0Zad+JdE6Z
                                                                                                                    format: "json",
                                                                                                                    simplify: true,
                                                                                                                }

                                                                                                                $.ajax({
                                                                                                                    // url: url,
                                                                                                                    url: "https://gw.api.taobao.com/router/rest?" + jerp.jsonToUrlParam(json),
                                                                                                                    method: 'post',
                                                                                                                    dataType: 'json',
                                                                                                                    async: true,
                                                                                                                    data: {
                                                                                                                        query_list: JSON.stringify({ "tid": "2820219243014500854", "oaid": "1KrYfXyHhIt1SEL1UicDSKSE5RPzgeexZAWunys1ZCwgiajo0G9oQsaiaMzhMRYodSIBPWUJ8s", "scene": 1006, "secret_no_days": 30 })
                                                                                                                    },
                                                                                                                    success: async function (e) {
                                                                                                                        if (e.receiver_list.length > 0) {
                                                                                                                            let r = e.receiver_list[0];

                                                                                                                            self.pick2info.receiverName = r.name;
                                                                                                                            self.pick2info.receiverMobile = r.mobile;
                                                                                                                            self.pick2info.receiverState = r.state;
                                                                                                                            self.pick2info.receiverCity = r.city;
                                                                                                                            self.pick2info.receiverDistrict = r.district;
                                                                                                                            self.pick2info.receiverAddress = r.address_detail;

                                                                                                                        }
                                                                                                                    }
                                                                                                                })
                                                                                                            }
                                                                                                        }
                                                                                                    })
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    })
                                                                                }
                                                                            }
                                                                            break;
                                                                        }
                                                                        default: {
                                                                            break;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        } else {
                                                            jerp.pxmu.toast("未找到对应订单，请查询后重试！");
                                                        }
                                                    },
                                                    // changeBindShop: function () {},
                                                    // changeWarehouse: function () {
                                                    //     this.submitInfo.outWarehouseId
                                                    //     this.submitInfo.retWarehouseId
                                                    // },
                                                    turnUpLeft: function () {
                                                        this.jTable.left.footer.nowTabInput--;
                                                        this.tableTurnLeft();
                                                    },
                                                    turnDownLeft: function () {
                                                        this.jTable.left.footer.nowTabInput++;
                                                        this.tableTurnLeft();
                                                    },
                                                    tableTurnLeft: function () {
                                                        // let maxTab = this.jTable.footer.showTabNum == 0 ? 1 : Math.ceil(this.list.length / this.jTable.footer.showTabNum);
                                                        if (this.jTable.left.footer.nowTabInput < 1) {
                                                            this.jTable.left.footer.nowTabInput = 1;
                                                        }
                                                        if (this.jTable.left.footer.nowTabInput > this.jTable.left.footer.maxTab) {
                                                            this.jTable.left.footer.nowTabInput = this.jTable.left.footer.maxTab;
                                                        }
                                                        this.jTable.left.footer.nowTab = this.jTable.left.footer.nowTabInput;
                                                    },
                                                    changeReceiver: function (type) { // 三级联动变更
                                                        if (type === 1) {
                                                            this.pick2info.receiverCity = '';
                                                        }
                                                        if (type === 2) {
                                                            this.pick2info.receiverDistrict = '';
                                                        }
                                                        // console.log(type, this.pick2info.receiverState, this.pick2info.receiverCity, this.pick2info.receiverDistrict);
                                                    },
                                                    priviewMouseDown: function (e) {
                                                        let self = this, mouseX = parseFloat(e.clientX),
                                                            mouseY = parseFloat(e.clientY),
                                                            box = document.getElementById('priview');
                                                        document.onmousemove = function (e) {
                                                            let targetX = parseFloat(e.clientX),
                                                                targetY = parseFloat(e.clientY);
                                                            self.priviewInfo.clientX += targetX - mouseX;
                                                            self.priviewInfo.clientY += targetY - mouseY;
                                                            mouseX = targetX;
                                                            mouseY = targetY;
                                                        }
                                                        document.onmouseup = function () {
                                                            document.onmousemove = null;
                                                            box.onmouseup = null;
                                                        }
                                                    },
                                                    payFeeChange: function () {
                                                        // console.log('payFeeChange');
                                                        if (this.payFee > this.totalPrice) {
                                                            this.payFee = this.totalPrice;
                                                        }
                                                        if (this.payFee < 0 || this.payFee == "") {
                                                            this.payFee = 0;
                                                        }
                                                        // this.submitInfo.surplusFee = jerp.math.jian(this.totalPrice, this.payFee);
                                                    },
                                                    surplusFeeChange: function () {
                                                        // console.log('surplusFeeChange');
                                                        if (this.submitInfo.surplusFee > this.totalPrice) {
                                                            this.submitInfo.surplusFee = this.totalPrice;
                                                        }
                                                        if (this.submitInfo.surplusFee < 0 || this.submitInfo.surplusFee == "") {
                                                            this.submitInfo.surplusFee = 0;
                                                        }
                                                        // this.payFee = jerp.math.jian(this.totalPrice, this.submitInfo.surplusFee);
                                                    },
                                                    privewShow: function () {
                                                        this.priviewInfo.priviewStatus = true;
                                                    },
                                                    privewClose: function () {
                                                        this.priviewInfo.priviewStatus = false;
                                                    },
                                                    init: function () {
                                                        this.list = [];

                                                        this.payFee = 0; // 抹零金额
                                                        this.flag = '0';
                                                        this.submitInfo.remark = '';

                                                        if (this.isBlank) {
                                                            this.memo = '缺货补发：';
                                                        } else {
                                                            this.memo = '';
                                                        }
                                                        this.submitInfo.customerId = ""; // this.distributor.distributorCompanyId, // 分销上id
                                                        this.submitInfo.payType = this.submitInfo.payType ? this.submitInfo.payType : "1"; // 支付方式
                                                        this.submitInfo.pickGoodsType = this.submitInfo.pickGoodsType ? this.submitInfo.pickGoodsType : 2; // 发货方式 1:自提 2:快递
                                                        this.submitInfo.surplusFee = 0; // 抹零金额
                                                        this.submitInfo.payInfos = [];
                                                        this.submitInfo.orders = [];

                                                        this.pick2info.receiverName = "";
                                                        this.pick2info.receiverMobile = "";
                                                        this.pick2info.receiverState = "";
                                                        this.pick2info.receiverCity = "";
                                                        this.pick2info.receiverDistrict = "";
                                                        this.pick2info.receiverAddress = ""; // 详细地址
                                                        this.pick2info.receiverZip = "";
                                                        this.pick2info.receiverPhone = "";

                                                        this.inputAdress = '';
                                                    },
                                                    changeDistributor: function (e) {
                                                        let self = this;
                                                        if (e.target.value != "" && this.bindShopList.length > 0) {
                                                            this.distributor = this.distributorList.filter(v => { return v.id == e.target.value })[0];
                                                            let i = 0, ds = this.distributor.aliasName; // 别名
                                                            for (; i < this.bindShopList.length; i++) {
                                                                let b = this.bindShopList[i];
                                                                if (b.priorityTitle.includes(ds)) {
                                                                    this.submitInfo.userId = b.userId;
                                                                    break;
                                                                }
                                                            }
                                                            if (this.submitInfo.userId == "") {
                                                                this.submitInfo.userId = this.bindShopList[0].userId;
                                                            }
                                                        } else {
                                                            this.distributor = "";
                                                        }
                                                        this.list.map(v => {
                                                            v.orderPrice = jerp.math.chen((self.commission[self.distributor.distributorLevel].type == 0 ? v.priceOutput : v.priceImport), self.commission[self.distributor.distributorLevel].pp)
                                                        });
                                                        // this.init();
                                                        // this.inputAdress = '';
                                                        this.getDefaultAddress();
                                                    },
                                                    getDefaultAddress: async function () {
                                                        let address = await jerp.getData({
                                                            url: '/dms/address/get/defaultAddress',
                                                            api_name: 'dms_address_get_defaultAddress',
                                                            method: 'get',
                                                        }, {
                                                            distributorCompanyId: this.distributor.distributorCompanyId,
                                                        });
                                                        // console.log('address: ', address);
                                                        if (address.addressee != "") {
                                                            this.pick2info.receiverName = address.addressee ? address.addressee : '';
                                                            this.pick2info.receiverMobile = address.mobilePhone ? address.mobilePhone : '';
                                                            this.pick2info.receiverState = address.province ? address.province : '';
                                                            this.pick2info.receiverCity = address.city ? address.city : '';
                                                            this.pick2info.receiverDistrict = address.country ? address.country : '';
                                                            this.pick2info.receiverAddress = address.addr ? address.addr : '';
                                                        } else {
                                                            this.inputAdress = '若腾阀门 15868001780 浙江省温州市龙湾区滨海区丁香路新川工业园3幢5号4楼';
                                                        }
                                                    },
                                                    // 查找关键词对应的商品
                                                    select: async function () {
                                                        let self = this;
                                                        /** 从缓存中获取数据，因为要同时获取销售价，所以暂时不用这个方法
                                                        let self = this;
                                                        let filter = this.selectOrderName.split(' ');
                                                        this.ordersChache.filter(v => {
                                                            let f = true;
                                                            for (let j = 0; j < filter.length; j++) {
                                                                if (!(v.title.indexOf(filter[j]) > -1)) {
                                                                    f = false;
                                                                    break;
                                                                }
                                                            }
                                                            if(f){
                                                                self.orderLists.push(v);
                                                            }
                                                        });
                                                         */
                                                        let orderName = this.selectOrderName;
                                                        if (orderName == "") { this.orderLists = []; return; }
                                                        let list = await jerp.getData({
                                                            // title: '',
                                                            url: '/item/list/all',
                                                            api_name: 'item_list_all',
                                                            method: 'post',
                                                        }, {
                                                            isAccurate: 0,
                                                            content: 'title',
                                                            text: orderName,
                                                            nameType: 1,
                                                            purchasePriceScope: 2,
                                                            specialFieldStatus: 2,
                                                            userId: -1,
                                                            companySourceType: 1,
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                        });
                                                        // console.log(JSON.parse(JSON.stringify(list)));
                                                        // console.log(self.orderHot);
                                                        // list.map(v => {
                                                        //     if (self.orderHot[v.outerId] === undefined) self.orderHot[v.outerId] = 0;
                                                        //     // console.log(self.orderHot[v.outerId]);
                                                        //     v.orderHot = parseInt(self.orderHot[v.outerId]);
                                                        // });
                                                        list = list.filter(v => {
                                                            let flag = false;
                                                            if (v.activeStatus == 1) {
                                                                flag = true;
                                                                if (self.orderHot[v.outerId] === undefined) self.orderHot[v.outerId] = 0;
                                                                // console.log(self.orderHot[v.outerId]);
                                                                v.orderHot = parseInt(self.orderHot[v.outerId]);
                                                                // v.sysConsigned = true;
                                                            }
                                                            return flag;
                                                        })
                                                        this.orderLists = list.sort((a, b) => { return b.orderHot - a.orderHot });
                                                        console.log(JSON.parse(JSON.stringify(this.orderLists)));
                                                    },
                                                    addOrder: async function (item) {
                                                        // console.log('item: ', item);
                                                        if (this.list.filter(v => { return v.outerId == item.outerId }).length > 0) return;
                                                        let self = this;

                                                        let goodsInfo = await jerp.getData({
                                                            url: '/item/v2/mini/list',
                                                            method: 'post',
                                                            return: 'data.list',
                                                        }, {
                                                            api_name: 'item_v2_mini_list',
                                                            needSuite: true,
                                                            withGoodsStock: true,
                                                            pageNo: 1,
                                                            pageSize: 50,
                                                            skuSizeSort: 1,
                                                            warehouseId: self.warehouse,
                                                            isAccurate: 1,
                                                            tileAllOuterId: item.outerId,
                                                            // tileSupplierId: ,
                                                            // supplierName: ,
                                                            source: 1,
                                                        });
                                                        // console.log('goodsInfo: ', goodsInfo);
                                                        if (goodsInfo.length > 0) {
                                                            // 304 内内外三通 DN40
                                                            let g = goodsInfo[0],
                                                                supplierId = g.bestItemSupplierBridge != undefined ? g.bestItemSupplierBridge.supplierId : 0,
                                                                price = g.bestItemSupplierBridge != undefined ?
                                                                    (g.bestItemSupplierBridge.supplierPurchasePrice > 0 ? g.bestItemSupplierBridge.supplierPurchasePrice : g.purchasePrice)
                                                                    : g.purchasePrice != undefined ? g.purchasePrice : 0;
                                                            // console.log('supplierId: ', supplierId);
                                                            // console.log('price1:', price);
                                                            if (supplierId != 0) {
                                                                let queryLastPrice = await jerp.getData({
                                                                    url: '/caigou/purchase/queryLastPrice',
                                                                    method: 'post',
                                                                    return: 'data',
                                                                }, {
                                                                    "warehouseId": self.warehouse,
                                                                    "itemSysIds": [item.sysItemId.toString()],
                                                                    "skuSysIds": ["0"],
                                                                    "supplierIds": [supplierId.toString()]
                                                                }, true);
                                                                // console.log('queryLastPrice: ', queryLastPrice);
                                                                // queryLastPrice
                                                                for (let i in queryLastPrice) {
                                                                    if (queryLastPrice[i].purchasePrice != undefined) {
                                                                        price = queryLastPrice[i].purchasePrice;
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            let codeList = await jerp.getGoodsCode(item.outerId, self.warehouse);
                                                            let codes = [];
                                                            if (codeList.length > 0) codeList.map(v => { codes.push(v.code) }); else codes.push('Z-Z-Z-Z-Z');
                                                            // console.log('price2:', price);
                                                            let priceOutput = item.priceOutput != undefined ? item.priceOutput : 0,
                                                                priceImport = item.priceImport != undefined ? item.priceImport : 0;
                                                            this.list.push({
                                                                outerId: item.outerId,
                                                                title: item.title,
                                                                priceOutput: priceOutput,
                                                                priceImport: priceImport,
                                                                newPurchasePrice: jerp.math.chu(price != undefined ? price : 0, 100),
                                                                orderPrice: jerp.math.chen((self.commission[self.distributor.distributorLevel].type == 0 ? priceOutput : priceImport), self.commission[self.distributor.distributorLevel].pp),
                                                                weight: item.weight,
                                                                code: codes.toString(),
                                                                // costPrice: costPrice,
                                                                num: 1,
                                                            });
                                                        }
                                                        // setTimeout(async () => {
                                                        //     let v = this.list.filter(v => { return v.outerId == item.outerId })[0],
                                                        //         newPurchase = await jerp.getLastPurchaseOrder({ outerId: item.outerId, title: item.title }),
                                                        //         codeList = await jerp.getGoodsCode(item.outerId);
                                                        //     // console.log(newPurchase, newPurchase.purchasePrice, newPurchase ? newPurchase.purchasePrice : "");
                                                        //     v.newPurchasePrice = newPurchase ? newPurchase.purchasePrice : "";
                                                        //     // console.log(item.title + '_codeList: ', codeList);
                                                        //     let codes = [];
                                                        //     if (codeList.length > 0) codeList.map(v => { codes.push(v.code) }); else codes.push('Z-Z-Z-Z-Z');
                                                        //     v.code = codes.toString();
                                                        // }, 0);
                                                    },
                                                    delOrder: function (index) {
                                                        this.list.splice(index, 1);
                                                    },
                                                    defaultAddress: function () {
                                                        this.inputAdress = "若腾阀门 15868001708 浙江省温州市龙湾区滨海工业园区丁香路新川工业园3栋5号4楼";
                                                    },
                                                    autoGetAddress: async function () {
                                                        /** 数据结构
                                                        {
                                                            "api_name": "张三，13175661013，浙江省温州市龙湾区",
                                                            "clueId": "628926625282560519",
                                                            "data": {
                                                                "address": {
                                                                    "city": "温州市",
                                                                    "detail": "",
                                                                    "district": "龙湾区",
                                                                    "province": "浙江省",
                                                                    "str": "张三"
                                                                },
                                                                "guess": {
                                                                    "guessC": false,
                                                                    "guessD": false,
                                                                    "guesssP": false
                                                                },
                                                                "name": "张三",
                                                                "phone": "13175661013"
                                                            },
                                                            "qTime": 13,
                                                            "result": 1
                                                        }
                                                         */
                                                        let address = await jerp.getData({
                                                            url: '/trade/aiParseAddress',
                                                            api_name: 'trade_aiParseAddress',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            "rawAddress": this.inputAdress
                                                        });
                                                        // <span style="width: 3.8rem;text-align: right;">姓名：</span>
                                                        // <span>手机号：</span>
                                                        // <span>省：</span>
                                                        // <span>市：</span>
                                                        // <span>区：</span>
                                                        // <span>详细地址：</span>
                                                        this.pick2info.receiverName = address.name;
                                                        this.pick2info.receiverMobile = address.phone;
                                                        this.pick2info.receiverState = address.address.province;
                                                        this.pick2info.receiverCity = address.address.city;
                                                        this.pick2info.receiverDistrict = address.address.district;
                                                        this.pick2info.receiverAddress = address.address.detail;
                                                    },
                                                    submit: async function (submitType) {
                                                        let self = this;

                                                        if (self.list.length == 0) {
                                                            jerp.pxmu.toast('请先选择商品');
                                                            return;
                                                        }
                                                        if (submitType == 1 && self.submitInfo.pickGoodsType == 2) {
                                                            if (self.pick2info.receiverName == "" ||
                                                                self.pick2info.receiverMobile == "" ||
                                                                self.pick2info.receiverState == "" ||
                                                                self.pick2info.receiverCity == "" ||
                                                                self.pick2info.receiverDistrict == "" ||
                                                                self.pick2info.receiverAddress == ""
                                                            ) {
                                                                jerp.pxmu.toast('请正确填写收件人信息');
                                                                return;
                                                            }
                                                        }
                                                        if (self.submitInfo.payType == "") {
                                                            jerp.pxmu.toast('请选择支付方式');
                                                            return;
                                                        }
                                                        let payInfos = self.payTypeList.filter(v => { return v.id == self.submitInfo.payType });
                                                        let payAccounts = self.payTypeList.filter(v => { return v.id == self.payAccount });


                                                        self.submitInfo.outWarehouseId = self.warehouse;
                                                        self.submitInfo.retWarehouseId = self.warehouse;

                                                        self.submitInfo.payInfos = [{
                                                            payType: self.submitInfo.payType,
                                                            payTypeName: payInfos[0].payName,
                                                            payFee: self.payFee,
                                                            accountId: "",
                                                            payAccount: "",
                                                            payName: self.submitInfo.payType != 1 ? (payAccounts.length > 0 ? payAccounts[0].payName : '') : '',
                                                            recordType: 0,
                                                            serialNumber: "",
                                                        }];
                                                        self.submitInfo.customerId = self.distributor.distributorCompanyId; // 分销上id

                                                        let orders = [];
                                                        for (let i = 0; i < self.list.length; i++) {
                                                            let o = self.list[i];
                                                            if (submitType == 1 && o.num == 0) {
                                                                jerp.pxmu.toast((i + 1) + ': 商品数量不能为0');
                                                                return;
                                                            }
                                                            orders.push({
                                                                outerId: o.outerId,
                                                                assistUnitNum: o.num, // 商品数量
                                                                totalNum: o.num, // 商品数量
                                                                num: o.num, // 商品数量
                                                                price: o.orderPrice, // 单价
                                                                payment: jerp.math.chen(o.num, o.orderPrice), // 合计 num*price
                                                                assistUnit: "",
                                                                assistUnitId: "",
                                                                numOfBox: 0,
                                                                numPerBox: 0,
                                                                saleRemark: "",
                                                                type: 1,
                                                            });
                                                            // console.log(self.orderHot[o.outerId]);
                                                            if (self.orderHot[o.outerId] === undefined) self.orderHot[o.outerId] = 0;
                                                            self.orderHot[o.outerId] = jerp.math.jia(self.orderHot[o.outerId], o.num);
                                                        }

                                                        localStorage.setItem('orderHot', JSON.stringify(self.orderHot));
                                                        // return;
                                                        self.submitInfo.orders = orders;

                                                        self.submitInfo.settleType = submitType;

                                                        for (let i = 0; i < self.expressList.length; i++) {
                                                            let ex = self.expressList[i];
                                                            if (ex.id == self.express) {
                                                                switch (self.SystemVersion) {
                                                                    case 1: {
                                                                        self.pick2info.templateId = ex.id;
                                                                        self.pick2info.templateType = ex.templateType;
                                                                        self.submitInfo.checkoutTime = new Date().getTime();
                                                                        break;
                                                                    }
                                                                    default: {
                                                                        self.pick2info.templateId = ex.templateId;
                                                                        self.pick2info.templateType = ex.templateType;
                                                                        self.submitInfo.logisticsCompanyId = ex.id;
                                                                        break;
                                                                    }
                                                                }
                                                                break;
                                                            }
                                                        }

                                                        let newOrder = await jerp.getData({
                                                            title: '单据创建中...',
                                                            url: '/trade/stall/saleTrade/settle',
                                                            method: 'post',
                                                            return: 'data',
                                                        }, self.submitInfo.pickGoodsType == 1 ? self.submitInfo : { ...self.submitInfo, ...self.pick2info }, 200, true);

                                                        if (Object.keys(newOrder).length == 0) {
                                                            jerp.pxmu.closeload('{}:创建失败，请联系管理员');
                                                            return;
                                                        }
                                                        // console.log('submitType: ', submitType);
                                                        if (submitType === 1) {
                                                            // console.log('newOrder: ', newOrder);
                                                            let sid = newOrder.sid, shortId = newOrder.tradeShortId; // 新生成的订单，可以用来插旗等
                                                            // console.log('sid: ', sid, 'shortId: ', shortId, sid !== undefined && sid !== null);
                                                            if (sid !== undefined && sid !== null) {
                                                                // 填充备注
                                                                self.priviewInfo.sid = sid;
                                                                self.priviewInfo.shortId = shortId;
                                                                self.priviewInfo.printTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                                self.priviewInfo.orders = JSON.parse(JSON.stringify(self.list));
                                                                self.priviewInfo.pick2info = JSON.parse(JSON.stringify(self.pick2info));
                                                                self.priviewInfo.remark = "分:" + self.distributor.distributorCompanyName + ";" + self.memo;
                                                                // console.log(self.flag, self.memo, self.flag != "" || self.memo != "");
                                                                if (self.priviewInfo.remark != "") {
                                                                    let setFlag = await jerp.getData({
                                                                        url: '/trade/sellermemoflag/update',
                                                                        api_name: 'trade_sellermemoflag_update',
                                                                        method: 'post',
                                                                        return: 'data',
                                                                    }, {
                                                                        memo: self.priviewInfo.remark,
                                                                        sid: sid,
                                                                        flag: self.flag,
                                                                        memoType: 0, // 0:未解决 1:已解决
                                                                    });

                                                                    if (setFlag.status == "success") {
                                                                        jerp.pxmu.closeload('备注完成');
                                                                    } else {
                                                                        jerp.pxmu.closeload('setFlag error:遇到错误，请联系管理员');
                                                                    }
                                                                } else {
                                                                    jerp.pxmu.closeload('完成');
                                                                }

                                                                // 设置空单
                                                                if (self.isBlank) {
                                                                    let setBlank = await jerp.getData({
                                                                        url: '/trade/scalp',
                                                                        // api_name: 'trade_scalp',
                                                                        method: 'post',
                                                                        return: 'data',
                                                                    }, {
                                                                        api_name: "trade_scalp",
                                                                        cancel: 0, // 设置空单
                                                                        sids: sid,
                                                                    });

                                                                    if (setBlank.status == "success") {
                                                                        jerp.pxmu.closeload('空单已设置');
                                                                    } else {
                                                                        jerp.pxmu.closeload('setBlank error:遇到错误，请联系管理员');
                                                                    }
                                                                }

                                                                self.privewShow();
                                                                self.init();
                                                            } else {
                                                                jerp.pxmu.closeload('创建失败，请联系管理员');
                                                            }
                                                        } else {
                                                            jerp.pxmu.closeload('订单已挂起');
                                                        }
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 进销存管理
                                        name: '进销存管理',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="flex-flow: column;">
                                                    <div class="jerpRow"> 
                                                        <div class="jerpCol">
                                                            <input v-model="selectList.goodsNoStr" placeholder="输入商品编码"></input>
                                                            <i class="btnInner" @click="selectListToggle(true, 'goodsNo')">+</i>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <input v-model="selectList.goodsNameStr" placeholder="输入商品名称"></input>
                                                            <i class="btnInner" @click="selectListToggle(true, 'goodsName')">+</i>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="select()">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <button class="btn" @click="submit()">提交</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>商品编码</span></div>
                                                                    <div class="jTable_col" style="flex: 4;"><span>商品名称</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>成本价（进价）</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>销售价</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list" >
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;padding-top: 1rem;padding-bottom: 1rem;"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;padding-top: 1rem;padding-bottom: 1rem;"><span>{{item.outerId}}</span></div>
                                                                            <div class="jTable_col" style="flex: 4;padding-top: 1rem;padding-bottom: 1rem;"><span>{{item.title}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;padding-top: 1rem;padding-bottom: 1rem;"><input type="rel" v-model="item.purchasePrice" :style="{'border':item.purchasePrice!=item.purchasePrice_bak?'4px solid green':''}" :title="'原值：'+item.purchasePrice_bak"/></div>
                                                                            <div class="jTable_col" style="flex: 2;padding-top: 1rem;padding-bottom: 1rem;"><input type="rel" v-model="item.sellingPrice" :style="{'border':item.sellingPrice!=item.sellingPrice_bak?'4px solid green':''}" :title="'原值：'+item.sellingPrice_bak"/></div>
                                                                        </div>
                                                                        <div class="jTable_sub">
                                                                            <div class="jTable_sub_inner">
                                                                                <div class="jTable_subTitle">
                                                                                    <div class="jTable_row">
                                                                                        <div class="jTable_col" style="flex: 2;"><span>拣货货位</span></div>
                                                                                        <div class="jTable_col" style="flex: 1;"><span>库存</span></div>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="jTable_subContent">
                                                                                    <div class="jTable_row" v-for="(subItem,subIndex) in item.stock.jx">
                                                                                        <div class="jTable_col" style="flex: 2;"><span>{{subItem.code}}</span></div>
                                                                                        <div class="jTable_col" style="flex: 1;"><input type="rel" v-model="subItem.num" :style="{'border':subItem.num!=subItem.num_bak?'4px solid green':''}" :title="'原值：'+subItem.num_bak"/></div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="jTable_sub_inner">
                                                                                <div class="jTable_subTitle">
                                                                                    <div class="jTable_row">
                                                                                        <div class="jTable_col" style="flex: 2;"><span>备货货位</span></div>
                                                                                        <div class="jTable_col" style="flex: 1;"><span>库存</span></div>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="jTable_subContent">
                                                                                    <div class="jTable_row" v-for="(subItem,subIndex) in item.stock.bh">
                                                                                        <div class="jTable_col" style="flex: 2;"><span>{{subItem.code}}</span></div>
                                                                                        <div class="jTable_col" style="flex: 1;"><input type="rel" v-model="subItem.num" :style="{'border':subItem.num!=subItem.num_bak?'4px solid green':''}" :title="'原值：'+subItem.num_bak"/></div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="selectList.selectListShow">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>批量添加</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="selectListToggle(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner">
                                                    <div class="inputCol">
                                                        <textarea v-model="selectList.multiStr"></textarea>
                                                    </div>
                                                </div>
                                                <div class="selectFooter">
                                                    <a class="btn" @click="selectListConfirm()">确定</a>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "selectList": {
                                                        "goodsNoStr": "",
                                                        "goodsNameStr": "",
                                                        "selectListShow": false,
                                                        "selectListType": "",
                                                        "multiStr": "",
                                                    },
                                                    list: [],
                                                },
                                                computed: {
                                                },
                                                methods: {
                                                    selectListToggle: function (status, type) {
                                                        if (status === false) {
                                                            // 关闭窗口
                                                        } else {
                                                            this.selectList.selectListType = type;
                                                            this.selectList.multiStr = "";
                                                            let multiStrList = [];
                                                            switch (type) {
                                                                case 'goodsNo': {
                                                                    multiStrList = this.selectList.goodsNoStr.split(',');
                                                                    break;
                                                                }
                                                                case 'goodsName': {
                                                                    multiStrList = this.selectList.goodsNameStr.split(',');
                                                                    break;
                                                                }
                                                            }
                                                            if (multiStrList.length > 0) {
                                                                let multiStr = '';
                                                                for (let i = 0; i < multiStrList.length; i++) {
                                                                    if (multiStrList[i] != "") {
                                                                        multiStr += multiStrList[i] + '\n';
                                                                    }
                                                                }
                                                                this.selectList.multiStr = multiStr;
                                                            }
                                                        }
                                                        this.selectList.selectListShow = status;
                                                    },
                                                    selectListConfirm: function () {
                                                        this.selectList[this.selectList.selectListType + 'Str'] = jerp.strProcessing(this.selectList.multiStr);
                                                        this.selectListsToggle(false);
                                                    },
                                                    select: async function (msg) {
                                                        let self = this,
                                                            nos = this.selectList.goodsNoStr,
                                                            names = this.selectList.goodsNameStr; // 商品名称只能一个一个查
                                                        jerp.pxmu.showload(msg);
                                                        if (nos == '' && names == '') {
                                                            jerp.pxmu.toast('请输入查找内容');
                                                            return;
                                                        }
                                                        let data = [];
                                                        if (nos != '') {
                                                            data = await jerp.getData({
                                                                url: '/item/queryListV2',
                                                            }, {
                                                                api_name: 'item_queryListV2',
                                                                pageNo: 1,
                                                                pageSize: 50,
                                                                isAccurate: 0,
                                                                outerId: nos,
                                                                isAccurateSku: 0,
                                                                tagQueryType: 0,
                                                                suiteQueryType: 0,
                                                                suiteSearchType: 1,
                                                                orderDesc: false,
                                                            })
                                                        }
                                                        if (names != '') {
                                                            let nameList = names.split(',');
                                                            for (let i = 0; i < nameList.length; i++) {
                                                                let dataByName = await jerp.getData({
                                                                    url: '/item/queryListV2',
                                                                }, {
                                                                    api_name: 'item_queryListV2',
                                                                    pageNo: 1,
                                                                    pageSize: 50,
                                                                    isAccurate: 0,
                                                                    title: nameList[i],
                                                                    isAccurateSku: 0,
                                                                    tagQueryType: 0,
                                                                    suiteQueryType: 0,
                                                                    suiteSearchType: 1,
                                                                    orderDesc: false,
                                                                })
                                                                if (dataByName !== undefined && dataByName.length > 0) {
                                                                    data.push(dataByName[0]);
                                                                }
                                                            }
                                                        }
                                                        let list = [];
                                                        for (let i = 0; i < data.length; i++) {
                                                            list.push({
                                                                sysItemId: data[i].sysItemId,
                                                                sysSkuId: data[i].sysSkuId,
                                                                outerId: data[i].outerId,
                                                                title: data[i].title,
                                                                purchasePrice: data[i].purchasePrice, // 成本价（进价）
                                                                purchasePrice_bak: data[i].purchasePrice,
                                                                sellingPrice: data[i].sellingPrice, // 销售价
                                                                sellingPrice_bak: data[i].sellingPrice,
                                                            });
                                                        }
                                                        let ids = [], stockObj = {};
                                                        list.map(v => { ids.push(v.outerId) });
                                                        let stockData = await jerp.getData({
                                                            url: '/wms/goodsSectionInventory/list',
                                                            return: 'data',
                                                        }, {
                                                            "userId": -1,
                                                            "warehouseId": self.warehouse,
                                                            "text": ids.toString(),
                                                            "queryOuterIdType": "0",
                                                            "supplierIds": [],
                                                            "categoryNameStr": null,
                                                            "page": {
                                                                "pageNo": 1,
                                                                "pageSize": 50
                                                            }
                                                        }, true)
                                                        if (stockData !== undefined && stockData.length > 0) {
                                                            for (let i = 0; i < stockData.length; i++) {
                                                                let d = stockData[i],
                                                                    outerId = d.sku.outerId,
                                                                    isJx = d.stockRegionName.includes("新仓-"),
                                                                    totalNum = d.sku.totalNum; // 在架数
                                                                if (stockObj[outerId] === undefined || stockObj[outerId] === null) {
                                                                    stockObj[outerId] = {
                                                                        jx: [],
                                                                        bh: []
                                                                    }
                                                                }
                                                                stockObj[outerId][isJx ? 'jx' : 'bh'].push({
                                                                    id: d.id,
                                                                    code: d.code,
                                                                    num: totalNum,
                                                                    num_bak: totalNum
                                                                });
                                                            }
                                                        }
                                                        for (let i = 0; i < list.length; i++) {
                                                            let d = list[i],
                                                                outerId = d.outerId;
                                                            if (stockObj[outerId]) {
                                                                d.stock = stockObj[outerId];
                                                            } else {
                                                                d.stock = {
                                                                    jx: [],
                                                                    bh: [],
                                                                };
                                                            }
                                                        }
                                                        // EE1622BXG201WSHJDN15,B7433BXG-I07-ZZGG001,A5513BXG-Q02-STS007
                                                        // console.log(JSON.parse(JSON.stringify(list)));
                                                        // console.log(JSON.parse(JSON.stringify(stockData)));
                                                        // console.log("stockObj: ", stockObj);
                                                        this.list = list;
                                                        jerp.pxmu.closeload();
                                                    },
                                                    submit: async function () {
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据'); return; }
                                                        jerp.pxmu.showload('数据提交中...');
                                                        let orderChange = [], stockChange = [];
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let h = this.list[i];
                                                            if (h.purchasePrice != h.purchasePrice_bak || h.sellingPrice != h.sellingPrice_bak) {
                                                                orderChange.push(h);
                                                            }
                                                            let stock = [...h.stock.jx, ...h.stock.bh];
                                                            for (let j = 0; j < stock.length; j++) {
                                                                let d = stock[j];
                                                                if (d.num != d.num_bak) {
                                                                    stockChange.push({
                                                                        sysItemId: h.sysItemId,
                                                                        sysSkuId: h.sysSkuId,
                                                                        id: d.id,
                                                                        code: d.code,
                                                                        num: d.num,
                                                                        num_bak: d.num_bak,
                                                                    });
                                                                }
                                                            }
                                                        }
                                                        // 档案update
                                                        for (let i = 0; i < orderChange.length; i++) {
                                                            let h = orderChange[i];
                                                            await jerp.getData({
                                                                url: '/item/saveItem',
                                                            }, {
                                                                "api_name": "item_saveItem",
                                                                outerId: h.outerId,
                                                                title: h.title,
                                                                sysItemId: h.sysItemId,
                                                                purchasePrice: h.purchasePrice,
                                                                sellingPrice: h.sellingPrice,
                                                            }, true);
                                                            await jerp.sleep();
                                                        }
                                                        // 货位update
                                                        for (let i = 0; i < stockChange.length; i++) {
                                                            let d = stockChange[i];
                                                            await jerp.getData({
                                                                url: '/wms/goodsSectionInventory/update',
                                                            }, {
                                                                api_name: 'wms_goodsSectionInventory_update',
                                                                goodsSectionId: d.id,
                                                                goodsSectionCode: d.code,
                                                                sysSkuId: d.sysSkuId,
                                                                sysItemId: d.sysItemId,
                                                                num: d.num,
                                                                async: false,
                                                                beforeNum: d.num_bak,
                                                            });
                                                            await jerp.sleep();
                                                        }
                                                        await jerp.sleep();
                                                        this.select('修改完成,重新获取数据...');
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 采购对单
                                        name: '采购对单',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="flex-flow: column;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>产品名称：</span>
                                                            <input type="text" style="width: 8rem;" v-model="selectOrderName" @keyup.enter="select"></input>
                                                            <button class="btn" style="margin-left: 0.3rem;" @click="select">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <button class="btn" @click="importShow(true)" style="font-size: 1rem;">导入</button>
                                                        <button class="btn" @click="Export" style="font-size: 1rem;">导出</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 4;">商品名称</div>
                                                                        <!-- <div class="jTable_col" style="flex: 1;">成本价</div> -->
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in orderListsAddFlag">
                                                                            <div class="jTable_row" :style="{'background':item.isAdd?'#ffa9a9':''}" style="cursor:pointer;" @dblclick="addOrder(item)"> <!-- onselectstart="return false" -->
                                                                                <div class="jTable_col" style="flex: 4; white-space: normal;"><span :title="item.orderHot">{{item.title}}</span></div>
                                                                                <!-- <div class="jTable_col" style="flex: 1;"><span>{{item.priceImport}}</span></div> -->
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:3;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                        <div class="jTable_col" style="flex: 1;">操作</div>
                                                                        <div class="jTable_col" style="flex: 8;"><span>商品名称</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>系统采购价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;" v-show="showMore"><span>采购价</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>数量</span></div>
                                                                        <div class="jTable_col" style="flex: 4;"><span>总价</span></div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row" style="cursor:pointer;">
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;">
                                                                                    <div class="operate_col"><a style="color: red;" @click="delOrder(index)">✖</a></div>
                                                                                    <!-- 
                                                                                        <div class="operate_col"><a >上</a></div>
                                                                                        <div class="operate_col"><a >下</a></div> 
                                                                                    -->
                                                                                </div>
                                                                                <div class="jTable_col" style="flex: 8; white-space: normal;"><span>{{item.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 4; white-space: normal;"><span>{{item.priceImportBak}}</span></div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" v-model="item.priceImport" :class="{'error':item.priceImportBak!=item.priceImport}"></input>
                                                                                </div>
                                                                                <div class="jTable_col" style="flex: 4;">
                                                                                    <input type="tel" step="1" v-model="item.num"></input>
                                                                                </div>
                                                                                <div class="jTable_col" style="flex: 4;"><span>{{orderTotalPrice(item)}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="selectListFrame" v-show="isStatus" style="width:20rem; height:6rem;left:auto;right:0;">
                                                <div class="selectHead">
                                                    <div class="headTitle">
                                                        <span>导入</span>
                                                    </div>
                                                    <div class="headBtn">
                                                        <a title="关闭" class="btn jerp_btn close" @click="importShow(false)"><i>x</i></a>
                                                    </div>
                                                </div>
                                                <div class="frame_inner" style="height:6rem;">
                                                    <div class="cwt_info">
                                                        <div class="jerpRow">
                                                            <div class="jerpCol">
                                                                <button class="btn" @click="modifyDL" style="font-size: 1rem;">下载模板</button>
                                                            </div>
                                                        </div>
                                                        <div class="jerpRow">
                                                            <div class="jerpCol">
                                                                <span>导入文件：</span>
                                                                <input id="jImport" type="file" style="width: 12rem;height:auto;" @change="Import"></input>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "isStatus": false,
                                                    "orderHot": {}, // 商品热度，用于商品排序
                                                    "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    "showMore": true, // 显示更多
                                                    "selectOrderName": '', // 查询用产品名称
                                                    // ordersChache: [], // 所有商品缓存
                                                    "orderLists": [], // 查询商品列表 priceOutput:销售, priceImport:成本
                                                    list: [], // 选中的商品列表
                                                },
                                                computed: {
                                                    orderTotalPrice: function () {
                                                        return item => {
                                                            return item.priceImport != "" && item.num != "" ? jerp.math.chen(item.priceImport, item.num) : 0;
                                                        }
                                                    },
                                                    orderListsAddFlag: function () {
                                                        let self = this, list = [];
                                                        for (let i = 0; i < self.orderLists.length; i++) {
                                                            let o = self.orderLists[i];
                                                            list.push({
                                                                ...o,
                                                                ...{
                                                                    isAdd: self.list.filter(v => { return v.outerId == o.outerId }).length > 0
                                                                }
                                                            })
                                                        }
                                                        // console.log(list);
                                                        return list;
                                                    },
                                                },
                                                methods: {
                                                    // 查找关键词对应的商品
                                                    select: async function () {
                                                        let self = this;
                                                        /** 从缓存中获取数据，因为要同时获取销售价，所以暂时不用这个方法
                                                        let self = this;
                                                        let filter = this.selectOrderName.split(' ');
                                                        this.ordersChache.filter(v => {
                                                            let f = true;
                                                            for (let j = 0; j < filter.length; j++) {
                                                                if (!(v.title.indexOf(filter[j]) > -1)) {
                                                                    f = false;
                                                                    break;
                                                                }
                                                            }
                                                            if(f){
                                                                self.orderLists.push(v);
                                                            }
                                                        });
                                                         */
                                                        let orderName = this.selectOrderName;
                                                        if (orderName == "") { this.orderLists = []; return; }
                                                        let list = await jerp.getData({
                                                            // title: '',
                                                            url: '/item/list/all',
                                                            api_name: 'item_list_all',
                                                            method: 'post',
                                                        }, {
                                                            isAccurate: 0,
                                                            content: 'title',
                                                            text: orderName,
                                                            nameType: 1,
                                                            purchasePriceScope: 2,
                                                            specialFieldStatus: 2,
                                                            userId: -1,
                                                            companySourceType: 1,
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                        });
                                                        // console.log(JSON.parse(JSON.stringify(list)));
                                                        // console.log(self.orderHot);
                                                        list.map(v => {
                                                            if (self.orderHot[v.outerId] === undefined) self.orderHot[v.outerId] = 0;
                                                            // console.log(self.orderHot[v.outerId]);
                                                            v.orderHot = parseInt(self.orderHot[v.outerId]);
                                                        });
                                                        this.orderLists = list.sort((a, b) => { return b.orderHot - a.orderHot });
                                                        // console.log(JSON.parse(JSON.stringify(this.orderLists)));
                                                    },
                                                    addOrder: async function (item, num = undefined, priceImport = undefined) {
                                                        if (this.list.filter(v => { return v.outerId == item.outerId }).length > 0) return;
                                                        let self = this,
                                                            goodsInfo = await jerp.getData({
                                                                url: '/item/v2/mini/list',
                                                                method: 'post',
                                                                return: 'data.list',
                                                            }, {
                                                                api_name: 'item_v2_mini_list',
                                                                needSuite: true,
                                                                withGoodsStock: true,
                                                                pageNo: 1,
                                                                pageSize: 50,
                                                                skuSizeSort: 1,
                                                                warehouseId: self.warehouse,
                                                                isAccurate: 1,
                                                                tileAllOuterId: item.outerId,
                                                                // tileSupplierId: ,
                                                                // supplierName: ,
                                                                source: 1,
                                                            });
                                                        if (goodsInfo.length > 0) {
                                                            // 304 内内外三通 DN40
                                                            let g = goodsInfo[0],
                                                                supplierId = g.bestItemSupplierBridge != undefined ? g.bestItemSupplierBridge.supplierId : 0,
                                                                price = g.bestItemSupplierBridge != undefined ?
                                                                    (g.bestItemSupplierBridge.supplierPurchasePrice > 0 ? g.bestItemSupplierBridge.supplierPurchasePrice : g.purchasePrice)
                                                                    : g.purchasePrice;
                                                            if (supplierId != 0) {
                                                                let queryLastPrice = await jerp.getData({
                                                                    url: '/caigou/purchase/queryLastPrice',
                                                                    method: 'post',
                                                                    return: 'data',
                                                                }, {
                                                                    "warehouseId": self.warehouse,
                                                                    "itemSysIds": [item.outerId],
                                                                    "skuSysIds": ["0"],
                                                                    "supplierIds": [supplierId]
                                                                }, true);
                                                                // queryLastPrice
                                                                for (let i in queryLastPrice) {
                                                                    price = queryLastPrice[i].purchasePrice;
                                                                    break;
                                                                }
                                                            }
                                                            // price = jerp.math.chu(goodsInfo.length > 0 ? (g.bestItemSupplierBridge.supplierPurchasePrice != undefined ? g.bestItemSupplierBridge.supplierPurchasePrice :
                                                            //     (g.itemSupplierBridgeList.length > 0 ? g.itemSupplierBridgeList[0].supplierPurchasePrice : item.priceImport)) : item.priceImport, 100);
                                                            this.list.push({
                                                                "outerId": item.outerId,
                                                                "title": g.title != undefined ? g.title : '错误',
                                                                "priceImport": priceImport ? priceImport : jerp.math.chu(price, 100),
                                                                "priceImportBak": jerp.math.chu(price, 100),
                                                                "num": num ? num : 1,
                                                            });
                                                        }
                                                    },
                                                    delOrder: function (index) {
                                                        this.list.splice(index, 1);
                                                    },
                                                    modifyDL: function () {
                                                        jerp.sheet.export([["<必填>商品编码", "采购数量", "辅助采购数量", "单价", "税率(%)", "供应商", "备注"]], '采购单v1导入模板');
                                                    },
                                                    importShow: function (status) {
                                                        this.isStatus = status;
                                                    },
                                                    Import: async function () {
                                                        let self = this, file = document.getElementById('jImport').files[0];
                                                        if (file != undefined) {
                                                            let importData = await jerp.sheet.import(file, [
                                                                { index: 1, name: 'outerId' },
                                                                { index: 2, name: 'num' },
                                                                { index: 4, name: 'priceImport' }, // 采购价
                                                            ]);
                                                            // console.log(importData);
                                                            if (!importData.suc) {
                                                                jerp.pxmu.toast(importData.msg);
                                                            } else {
                                                                let sids = [];
                                                                importData.data.map(v => {
                                                                    // sids.push(v.outerId)
                                                                    self.addOrder({ "outerId": v.outerId }, v.num, v.priceImport);
                                                                });
                                                                // let goodsData = await jerp.getData({
                                                                //     url: '/item/queryListV2',
                                                                //     method: 'post',
                                                                //     return: 'data.list',
                                                                // }, {
                                                                //     api_name: 'item_queryListV2',
                                                                //     pageNo: 1,
                                                                //     pageSize: 200,
                                                                //     isAccurate: 0,
                                                                //     outerId: sids.toString(),
                                                                //     isAccurateSku: 0,
                                                                //     tagQueryType: 0,
                                                                //     suiteQueryType: 0,
                                                                //     suiteSearchType: 1,
                                                                //     orderDesc: false,
                                                                // });
                                                                // for (let i = 0; i < importData.data.length; i++) {
                                                                //     let d = importData.data[i];
                                                                //     let g = goodsData.filter(v => { if (v.outerId == d.outerId) return v });
                                                                //     self.list.push({
                                                                //         outerId: d.outerId,
                                                                //         title: g.length > 0 ? g[0].title : '',
                                                                //         priceImportBak: g.length > 0 ? g[0].purchasePrice : -10000,
                                                                //         priceImport: d.priceImport,
                                                                //         num: d.num,
                                                                //     });
                                                                // }
                                                            }
                                                        }
                                                    },
                                                    Export: function () {
                                                        let self = this, data = [];
                                                        data.push(["<必填>商品编码", "采购数量", "辅助采购数量", "单价", "税率(%)", "供应商", "备注"])
                                                        for (let i = 0; i < self.list.length; i++) {
                                                            let d = self.list[i];
                                                            data.push([d.outerId, d.num, '', d.priceImport, '', '', ''])
                                                        }
                                                        jerp.sheet.export(data, '采购对单导出');
                                                    },
                                                },
                                            })
                                        }
                                    },
                                    { // 疑似可合单
                                        name: '疑似可合单',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info" style="display:flex;flex-flow:column;">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <!-- <button class="btn copy" @click="export2Excel()">导出</button> -->
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "list": [],
                                                },
                                                mounted: function () {
                                                },
                                                methods: {

                                                },
                                            })
                                        }
                                    },
                                    { // 批量包装验货
                                        name: '批量包装验货',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;">快递单号<button @click="submit">提交</button></div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_row">
                                                                            <textarea style="width: calc(100% - 0.6rem);height: 34.8rem;margin: 0.3rem;border-radius: 0.5rem;" v-model="expressNos"></textarea>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:3;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row">
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "expressNos": "",
                                                    "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    list: [], // 选中的商品列表
                                                },
                                                methods: {
                                                    submit: async function () {
                                                        let sids = jerp.strProcessing(this.multiStr).split(',');
                                                        for (let i = 0; i < sids.length; i++) {
                                                            let sid = sids[i];
                                                            let d = await jerp.getData({
                                                                url: '/trade/search/mix',
                                                                method: 'get',
                                                                return: 'data.list'
                                                            });
                                                        }
                                                    },
                                                },
                                            })
                                        }
                                    }
                                ]
                            },
                            { // 数据
                                name: '数据',
                                subName: '',
                                active: false,
                                status: false,
                                role: [],
                                child: [
                                    { // 拣选绩效
                                        name: '拣选绩效',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>日期</span>
                                                            <input type="date" max="timeEnd" v-model="timeStart"></input>
                                                            <span>-</span>
                                                            <input type="date" min="timeStart" v-model="timeEnd"></input>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <button class="btn copy" @click="export2Excel()">导出csv</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>员工</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>订单数</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>商品数量</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>商品种类</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>商品重量</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>实付金额</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>总积分</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>日期</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.staffName}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.tradeCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemKindCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.netWeight}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.payment}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.sumCredit}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{createStr(item)}}</span></div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    copyAvailable: false,
                                                    timeStart: '2024-10-17',
                                                    timeEnd: '2024-10-17',
                                                    list: [],
                                                    nowTime: null,
                                                },
                                                computed: {
                                                    createStr: function () {
                                                        return v => {
                                                            return jerp.getFormatDate(new Date(v.created), 'yyyy-MM-dd');
                                                        }
                                                    }
                                                },
                                                mounted: function () {
                                                    this.timeEnd = jerp.getFormatDate(new Date(), 'yyyy-MM-dd');
                                                    let y = new Date().getFullYear(), m = new Date().getMonth() + 1, d = new Date().getDate();
                                                    this.timeStart = jerp.getFormatDate(new Date(y + "-" + m + "-1"), 'yyyy-MM-dd');
                                                },
                                                methods: {
                                                    updateTitle: function (isProcessed, total) {
                                                        // jerp.winSubtitle = `( <span style="color:green;">${this.list.length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        jerp.winSubtitle = `${this.nowTime}`;
                                                        if (isProcessed == total && total != 0) {
                                                            // jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    check: async function () {
                                                        if (this.timeStart == '' || this.timeEnd == "") { jerp.pxmu.toast('请填写正确的时间!'); return; }

                                                        let self = this,
                                                            selectTime = new Date(this.timeStart + " 00:00:00"),
                                                            endTime = new Date(this.timeEnd + " 00:00:00"),
                                                            list = [];
                                                        // console.log('selectTime-0: ', selectTime);
                                                        self.list = [];
                                                        self.copyAvailable = false;
                                                        self.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
                                                        self.updateTitle(0, 0);

                                                        for (let i = 0; ; i++) {
                                                            if (selectTime > endTime || selectTime > new Date()) {
                                                                break;
                                                            }
                                                            let datas = await jerp.getData({
                                                                title: '正在获取' + jerp.getFormatDate(selectTime, 'yyyy-MM-dd') + '的数据……',
                                                                url: '/report/trade/pick/list',
                                                                api_name: 'report_trade_pick_list',
                                                                method: 'get',
                                                            }, {
                                                                startTime: selectTime.getTime(),
                                                                endTime: selectTime.getTime() + 24 * 60 * 60 * 1000 - 1000,
                                                                // text: 
                                                                // scalping: 
                                                                // userIds: 
                                                                // warehouseIds: 
                                                                pageNo: 1,
                                                                pageSize: 50,
                                                            });
                                                            list = [...list, ...datas];
                                                            self.list = list;
                                                            selectTime.setDate(selectTime.getDate() + 1);
                                                        }
                                                        // console.log(list);
                                                        self.copyAvailable = true;
                                                        jerp.pxmu.closeload();
                                                    },
                                                    export2Excel: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let content = '';
                                                        let copyList = {
                                                            _index: '序号',
                                                            staffName: '员工',
                                                            waveCount: '波次数',
                                                            tradeCount: '订单数',
                                                            sumCredit: '总积分',
                                                            itemCount: '商品数量',
                                                            itemKindCount: '商品种类',
                                                            netWeight: '商品总重量',
                                                            payment: '实付金额',
                                                            oneItemTradeCount: '一单一件订单数',
                                                            oneItemCredit: '一单一件总积分',
                                                            oneItemCount: '一单一件商品数',
                                                            oneItemKindCount: '一单一件种类',
                                                            oneItemTradeNetWeight: '一单一件总重量',
                                                            manyItemTradeCount: '一单多件订单数',
                                                            manyItemCredit: '一单多件总积分',
                                                            manyItemCount: '一单多件商品数',
                                                            manyItemKindCount: '一单多件种类',
                                                            manyItemTradeNetWeight: '一单多件总重量',
                                                            itemSuitCount: '商品数量（按套件算）',
                                                            itemSuitKindCount: '商品种类（按套件算）',
                                                            created: '日期',
                                                        }
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            content += '"' + copyList[i] + '"\t,';
                                                        }
                                                        content += '\n';
                                                        let index = 0;
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let h = this.list[i];
                                                            for (let j in copyList) {
                                                                if (j == "_index") {
                                                                    content += '"' + (++index) + '"\t,';
                                                                } else if (j == "created") {
                                                                    content += '"' + jerp.getFormatDate(new Date(h[j]), 'yyyy-MM-dd') + '"\t,';
                                                                } else {
                                                                    content += '"' + h[j] + '"\t,';
                                                                }
                                                            }
                                                            content += '\n';
                                                        }
                                                        jerp.downloadCSV(content, "拣选绩效");
                                                        // jerp.copy(content);
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 包装绩效
                                        name: '包装绩效',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特', '叶小珍', '王梦璇'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>日期</span>
                                                            <input type="date" max="timeEnd" v-model="timeStart"></input>
                                                            <span>-</span>
                                                            <input type="date" min="timeStart" v-model="timeEnd"></input>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <button class="btn copy" @click="export2Excel()">导出</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>员工</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>订单数</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>商品数量</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>商品种类</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>实付金额</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>重量(kg)</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>总积分</span></div>
                                                                    <div class="jTable_col" style="flex: 2;"><span>日期</span></div>
                                                                </div>
                                                            </div>
                                                            <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.staffName}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.packCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemKindCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.payment}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.weight}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.sumCredit}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{createStr(item)}}</span></div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    copyAvailable: false,
                                                    timeStart: '2024-10-17',
                                                    timeEnd: '2024-10-17',
                                                    list: [],
                                                    nowTime: null,
                                                },
                                                computed: {
                                                    createStr: function () {
                                                        return v => {
                                                            return jerp.getFormatDate(new Date(v.created), 'yyyy-MM-dd');
                                                        }
                                                    }
                                                },
                                                mounted: function () {
                                                    this.timeEnd = jerp.getFormatDate(new Date(), 'yyyy-MM-dd');
                                                    let y = new Date().getFullYear(), m = new Date().getMonth() + 1, d = new Date().getDate();
                                                    this.timeStart = jerp.getFormatDate(new Date(y + "-" + m + "-1"), 'yyyy-MM-dd');
                                                },
                                                methods: {
                                                    init: function () {
                                                        this.list = [];
                                                    },
                                                    updateTitle: function (isProcessed, total) {
                                                        // jerp.winSubtitle = `( <span style="color:green;">${this.list.length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        // jerp.winSubtitle = `${this.nowTime}`;
                                                        // if (isProcessed == total && total != 0) {
                                                        //     jerp.pxmu.closeload();
                                                        // }
                                                        jerp.winTitle.get = isProcessed;
                                                        jerp.winTitle.total = total;
                                                        jerp.winTitle.getTime = this.nowTime;
                                                    },
                                                    check: async function () {
                                                        this.init();
                                                        if (this.timeStart == '' || this.timeEnd == "") { jerp.pxmu.toast('请填写正确的时间!'); return; }
                                                        let self = this,
                                                            selectTime = new Date(this.timeStart + " 00:00:00"),
                                                            endTime = new Date(this.timeEnd + " 23:59:59"),
                                                            list = [];
                                                        // console.log('selectTime-0: ', selectTime);
                                                        self.copyAvailable = false;
                                                        self.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss');
                                                        self.updateTitle(0, 0);

                                                        let errorTimes = 0;
                                                        for (let i = 0; ; i++) {
                                                            await jerp.sleep(1000);
                                                            if (selectTime > endTime || selectTime > new Date()) {
                                                                break;
                                                            }
                                                            if (errorTimes >= 10) {
                                                                jerp.pxmu.closeload("错误！请联系管理员！", 5000);
                                                                break;
                                                            }
                                                            let datas = await jerp.getData({
                                                                title: '正在获取' + jerp.getFormatDate(selectTime, 'yyyy-MM-dd') + '的数据……',
                                                                url: '/report/trade/pack/list',
                                                                // api_name: 'report_trade_pack_list',
                                                                method: 'get',
                                                                return: 'data.list',
                                                                headers: {
                                                                    'module-path': '/report/pack_perform_next/',
                                                                    'content-type': 'application/json',
                                                                }
                                                            }, {
                                                                pageNo: 1,
                                                                pageSize: 50,
                                                                startTime: selectTime.getTime(),
                                                                endTime: selectTime.getTime() + 24 * 60 * 60 * 1000 - 1000,
                                                                // text: '',
                                                                // scalping: '',
                                                                // userIds: '',
                                                                // staffIds: '',
                                                                // warehouseIds: '',
                                                                api_name: 'report_trade_pack_list',
                                                            });
                                                            // console.log('datas: ', datas, datas.length);
                                                            if (datas) {
                                                                if (datas.length > 0) {
                                                                    errorTimes = 0;
                                                                    let weight = 0;
                                                                    for (let j = 0; j < datas.length; j++) {
                                                                        await jerp.sleep(1000);
                                                                        if (errorTimes >= 10) {
                                                                            break;
                                                                        }
                                                                        let l = datas[j];
                                                                        let staffId = l.staffId;
                                                                        let orders = await jerp.getData({
                                                                            url: '/report/trade/pack/staff/list',
                                                                            api_name: 'report_trade_pack_staff_list',
                                                                            method: 'get',
                                                                            headers: {
                                                                                'module-path': '/report/pack_perform_next/',
                                                                                'content-type': 'application/json',
                                                                            }
                                                                        }, {
                                                                            startTime: selectTime.getTime(),
                                                                            endTime: selectTime.getTime() + 24 * 60 * 60 * 1000 - 1000,
                                                                            pageNo: 1,
                                                                            pageSize: 1000,
                                                                            staffId: staffId,
                                                                        });
                                                                        if (orders && orders.length > 0) {
                                                                            errorTimes = 0;
                                                                            for (let z = 0; z < orders.length; z++) {
                                                                                weight = jerp.math.jia(weight, orders[z].actualWeight);
                                                                            }
                                                                            l.weight = weight;
                                                                        } else {
                                                                            if (orders.success == false) {
                                                                                j--; errorTimes++;
                                                                                await jerp.sleep(10000);
                                                                            }
                                                                        }
                                                                    }
                                                                    if (errorTimes > 0) {
                                                                        jerp.pxmu.closeload('数据获取错误，请联系管理员', 10000);
                                                                        break;
                                                                    }
                                                                    list = [...list, ...datas];
                                                                    self.list = list;
                                                                }
                                                                selectTime.setDate(selectTime.getDate() + 1);
                                                            } else {
                                                                // console.log('接口获取错误');
                                                                if (datas.success == false) {
                                                                    i--; errorTimes++;
                                                                    await jerp.sleep(10000);
                                                                }
                                                            }
                                                        }
                                                        self.copyAvailable = true;
                                                        jerp.pxmu.closeload();
                                                    },
                                                    export2Excel: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }
                                                        let exData = [], exRow = [];
                                                        let content = '';
                                                        let copyList = {
                                                            _index: '序号',
                                                            staffName: '员工',
                                                            packCount: '订单数',
                                                            itemCount: '订单商品数量',
                                                            itemKindCount: '包装商品种类',
                                                            weight: '重量(kg)',
                                                            payment: '实付金额',
                                                            sumCredit: '总积分',
                                                            oneItemTradeCount: '一单一件订单数',
                                                            oneItemCount: '一单一件商品数',
                                                            oneItemCredit: '一单一件总积分',
                                                            manyItemTradeCount: '一单多件订单数',
                                                            manyItemCount: '一单多件商品数',
                                                            manyItemCredit: '一单多件总积分',
                                                            created: '日期',
                                                        }
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            exRow.push(copyList[i]);
                                                            // content += '"' + copyList[i] + '"\t,';
                                                        }
                                                        exData.push(exRow);
                                                        // content += '\n';
                                                        let index = 0;
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let h = this.list[i], exRow = [];
                                                            for (let j in copyList) {
                                                                if (j == "_index") {
                                                                    exRow.push(++index);
                                                                    // content += '"' + (++index) + '"\t,';
                                                                } else if (j == "created") {
                                                                    exRow.push(jerp.getFormatDate(new Date(h[j]), 'yyyy-MM-dd'));
                                                                    // content += '"' + jerp.getFormatDate(new Date(h[j]), 'yyyy-MM-dd') + '"\t,';
                                                                } else {
                                                                    exRow.push(h[j]);
                                                                    // content += '"' + h[j] + '"\t,';
                                                                }
                                                            }
                                                            exData.push(exRow);
                                                            // content += '\n';
                                                        }
                                                        jerp.sheet.export(exData, "拣选绩效");
                                                        // jerp.downloadCSV(content, "拣选绩效");
                                                        // jerp.copy(content);
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 财务报表
                                        name: '财务报表',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['x'], // , '叶小珍', '王梦璇'
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow">
                                                        <div class="jerpCol">
                                                            <span>日期</span>
                                                            <input type="date" max="timeEnd" v-model="timeStart"></input>
                                                            <span>-</span>
                                                            <input type="date" min="timeStart" v-model="timeEnd"></input>
                                                        </div>
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="check()">查询</button>
                                                        </div>
                                                    </div>
                                                    <div class="btnSubmit">
                                                        <button class="btn copy" @click="export2Excel()">导出csv</button>
                                                    </div>
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div class="jTable">
                                                            <div class="jTable_title">
                                                                <div class="jTable_row">
                                                                    <div class="jTable_col" style="flex: 1;"><span>序号</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>付款时间</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>销售数量</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>销售金额</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>退货数量</span></div>
                                                                    <div class="jTable_col" style="flex: 1;"><span>实退金额</span></div>
                                                                </div>
                                                            </div>
                                                            <!-- <div class="jTable_content">
                                                                <div class="jTable_content_c">
                                                                    <div class="jTable_content_row" v-for="(item,index) in list">
                                                                        <div class="jTable_row">
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{index+1}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{item.staffName}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.packCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.itemKindCount}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.payment}}</span></div>
                                                                            <div class="jTable_col" style="flex: 1;"><span>{{item.sumCredit}}</span></div>
                                                                            <div class="jTable_col" style="flex: 2;"><span>{{createStr(item)}}</span></div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div> -->
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    copyAvailable: false,
                                                    timeStart: '2024-10-17',
                                                    timeEnd: '2024-10-17',
                                                    list: [],
                                                    nowTime: null,
                                                },
                                                computed: {
                                                    createStr: function () {
                                                        return v => {
                                                            return jerp.getFormatDate(new Date(v.created), 'yyyy-MM-dd');
                                                        }
                                                    }
                                                },
                                                mounted: function () {
                                                    this.timeEnd = jerp.getFormatDate(new Date(), 'yyyy-MM-dd');
                                                    let y = new Date().getFullYear(), m = new Date().getMonth() + 1, d = new Date().getDate();
                                                    this.timeStart = jerp.getFormatDate(new Date(y + "-" + m + "-1"), 'yyyy-MM-dd');
                                                },
                                                methods: {
                                                    updateTitle: function (isProcessed, total) {
                                                        jerp.winSubtitle = `( <span style="color:green;">${this.list.length}</span> / <span style="color:blue;">${isProcessed}</span> / ${total} ) ${this.nowTime}`;
                                                        if (isProcessed == total && total != 0) {
                                                            // jerp.pxmu.closeload();
                                                        }
                                                    },
                                                    check: async function () {
                                                        if (this.timeStart == '' || this.timeEnd == "") { jerp.pxmu.toast('请填写正确的时间!'); return; }

                                                        let self = this,
                                                            timeStart = new Date(this.timeStart + " 00:00:00"),
                                                            endTime = new Date(this.timeEnd + " 00:00:00"),
                                                            // data = [],
                                                            list = {};
                                                        // console.log('selectTime-0: ', selectTime);
                                                        self.list = [];
                                                        self.copyAvailable = false;
                                                        self.nowTime = jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
                                                        self.updateTitle(0, 0);

                                                        // for (let i = 0; ; i++) {
                                                        // if (selectTime > endTime) {
                                                        //     break;
                                                        // }
                                                        let data = await jerp.getData({
                                                            title: '获取数据中……',
                                                            url: '/report/sale/dimensions/finance/list',
                                                            api_name: 'report_sale_dimensions_finance_list',
                                                            method: 'post',
                                                        }, {
                                                            pageId: 1325,
                                                            // pageId? 不知道怎么来的
                                                            pageNo: 1,
                                                            pageSize: 1000,
                                                            queryFlag: 'order',
                                                            startTime: timeStart.getTime(),
                                                            endTime: endTime.getTime(),
                                                            vipSign: false,
                                                            sysStatus: 'sys_consign',
                                                            itemFlag: 0,
                                                            containTradeOut: true,
                                                            onlyTradeOut: false,
                                                            containNonConsign: true,
                                                            containCancel: false,
                                                            buyerNickSelectAll: false,
                                                            isOuterIdFuzzy: 0,
                                                            matchFlag: 1,
                                                            virtualFlag: 1,
                                                            showSuit: 0,
                                                            itemTagQueryType: 0,
                                                            afterSaleTimeType: 'finish',
                                                            authorType: 'name',
                                                            provinceCityAreaFilter: {},
                                                            showSysItem: 0,
                                                            shouldSort: false,
                                                        });
                                                        // data = [...data, ...getDatas];
                                                        // selectTime.setDate(selectTime.getDate() + 1);
                                                        // }
                                                        // console.log(data);
                                                        for (let i = 0; i < data.length; i++) {
                                                            let h = data[i];
                                                            /**
                                                                "sid": 5008790666468283, // 订单号
                                                                "tradeShortId": 1549830, // 短号
                                                                "payTime": 1727690423000, // 付款时间
                                                                "itemCount": 50, // 销售数量
                                                                "saleMoney": 210, // 销售金额
                                                                "itemCost": 180, // 销售成本
                                                                "refundItemCount": 0, // 退货数量
                                                                "rawRefundMoney": 0, // 退款金额
                                                                "grossProfit": 30, // 销售毛利  
                                                             */
                                                            let payTime = jerp.getFormatDate(new Date(h.payTime), 'yyyy-MM-dd'),
                                                                afterSaleApplyTime = jerp.getFormatDate(new Date(h.afterSaleApplyTime), 'yyyy-MM-dd'),
                                                                l = {};
                                                            if (list[payTime]) {
                                                                l = list[payTime];
                                                            } else {
                                                                l = {
                                                                    itemCount: 0,
                                                                    saleMoney: 0,
                                                                    itemCost: 0,
                                                                    refundItemCount: 0,
                                                                    rawRefundMoney: 0,
                                                                    grossProfit: 0,
                                                                    order: [],
                                                                    AfterOrder: [],
                                                                };
                                                                list[payTime] = l;
                                                            }
                                                            let o = l.order.filter(v => { return v.sid == h.sid }),
                                                                od = {};
                                                            if (o.length == 0) {
                                                                od = {
                                                                    "sid": h.sid, //   订单号
                                                                    "tradeShortId": h.tradeShortId, // 短号
                                                                    "payTime": payTime, // 付款时间
                                                                    "saleMoney": 0,
                                                                };
                                                                l.order.push(od);
                                                            } else {
                                                                od = o[0];
                                                            }
                                                            let ao = l.order.filter(v => { return v.sid == h.sid }),
                                                                aod = {};
                                                            if (ao.length == 0) {
                                                                aod = {
                                                                    "sid": h.sid, //   订单号
                                                                    "tradeShortId": h.tradeShortId, // 短号
                                                                    "afterSaleApplyTime": afterSaleApplyTime, // 售后时间
                                                                    "saleMoney": 0,
                                                                };
                                                                l.order.push(aod);
                                                            } else {
                                                                aod = ao[0];
                                                            }
                                                            // afterSaleApplyTime
                                                            od.saleMoney += h.saleMoney;
                                                            l.itemCount += h.itemCount;
                                                            l.saleMoney += h.saleMoney;
                                                            l.itemCost += h.itemCost;
                                                            l.refundItemCount += h.refundItemCount;
                                                            l.rawRefundMoney += h.rawRefundMoney;
                                                            l.grossProfit += h.grossProfit;
                                                        }
                                                        // console.log(list);
                                                        // self.list = list;
                                                        self.copyAvailable = true;
                                                        jerp.pxmu.closeload();
                                                    },
                                                    export2Excel: function () {
                                                        if (!this.copyAvailable) { jerp.pxmu.toast('数据获取中，请稍后再试……'); return; }
                                                        if (this.list.length == 0) { jerp.pxmu.toast('请先获取数据……'); return; }

                                                        let content = '';
                                                        let copyList = {
                                                            _index: '序号',
                                                            staffName: '员工',
                                                            packCount: '订单数',
                                                            itemCount: '订单商品数量',
                                                            itemKindCount: '包装商品种类',
                                                            payment: '实付金额',
                                                            sumCredit: '总积分',
                                                            oneItemTradeCount: '一单一件订单数',
                                                            oneItemCount: '一单一件商品数',
                                                            oneItemCredit: '一单一件总积分',
                                                            manyItemTradeCount: '一单多件订单数',
                                                            manyItemCount: '一单多件商品数',
                                                            manyItemCredit: '一单多件总积分',
                                                            created: '日期',
                                                        }
                                                        // 先创建标题
                                                        for (let i in copyList) {
                                                            content += '"' + copyList[i] + '"\t,';
                                                        }
                                                        content += '\n';
                                                        let index = 0;
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            let h = this.list[i];
                                                            for (let j in copyList) {
                                                                if (j == "_index") {
                                                                    content += '"' + (++index) + '"\t,';
                                                                } else if (j == "created") {
                                                                    content += '"' + jerp.getFormatDate(new Date(h[j]), 'yyyy-MM-dd') + '"\t,';
                                                                } else {
                                                                    content += '"' + h[j] + '"\t,';
                                                                }
                                                            }
                                                            content += '\n';
                                                        }
                                                        jerp.downloadCSV(content, "拣选绩效");
                                                        // jerp.copy(content);
                                                    }
                                                },
                                            })
                                        }
                                    },
                                ]
                            },
                            { // 其他
                                name: '其他',
                                subName: '',
                                active: false,
                                status: false,
                                role: [],
                                child: [
                                    { // 随机数
                                        name: '随机数',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲', '王特'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_info">
                                                    <div class="jerpRow"> 
                                                        <div class="jerpCol">
                                                            <span>数字范围：</span>
                                                            <input type="tel" v-model="startNum"></input>
                                                            <span> - </span>
                                                            <input type="tel" v-model="endNum"></input>
                                                        </div> 
                                                        <div class="jerpCol">
                                                            <span>获取数量：</span>
                                                            <input type="tel" v-model="getNum"></input>
                                                        </div> 
                                                        <div class="jerpCol">
                                                            <button class="btn" @click="submit()">确定</button>
                                                        </div>
                                                    </div>
                                                    <!-- <div class="btnSubmit">
                                                        <button class="btn copy" @click="copy2Excel('all')">导出csv</button>
                                                        <button class="btn copy" @click="copyDetails2Excel('all')">详情</button>
                                                    </div> -->
                                                </div>
                                                <div class="cwt_main" style="flex: 4; display: flex;">
                                                    <div class="cwt_inner">
                                                        <div v-for="item in list">{{item}}</div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    list: [],
                                                    startNum: 1,
                                                    endNum: 100,
                                                    getNum: 10,
                                                    nowTime: jerp.getFormatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'),
                                                },
                                                mounted: function () {
                                                    this.startNum = window.localStorage.getItem('random_startNum') ? window.localStorage.getItem('random_startNum') : 1;
                                                    this.endNum = window.localStorage.getItem('random_endNum') ? window.localStorage.getItem('random_endNum') : 100;
                                                    this.getNum = window.localStorage.getItem('random_getNum') ? window.localStorage.getItem('random_getNum') : 10;
                                                },
                                                methods: {
                                                    submit: function () {
                                                        if (this.startNum > this.endNum) { let a = this.endNum; this.endNum = this.startNum; this.startNum = a; }
                                                        if (this.getNum > this.endNum - this.startNum + 1) { jerp.pxmu.toast('获取数量不能大于总数'); return; }
                                                        window.localStorage.setItem('random_startNum', this.startNum);
                                                        window.localStorage.setItem('random_endNum', this.endNum);
                                                        window.localStorage.setItem('random_getNum', this.getNum);
                                                        let list = [];
                                                        for (; ;) {
                                                            if (list.length >= this.getNum) break;
                                                            let r = Math.floor(Math.random() * (this.endNum + 1 - this.startNum) + this.startNum);
                                                            if (r >= this.startNum && r <= this.endNum) {
                                                                let f = list.filter(v => { return v == r });
                                                                if (f.length == 0) {
                                                                    list.push(r);
                                                                }
                                                            }
                                                        }
                                                        this.list = list.sort((a, b) => { return a.title - b.title });
                                                    },
                                                },
                                            })
                                        }
                                    },
                                    { // 测试
                                        name: '测试',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                                <input id="jFile" type="file" @change="testRD()"/>
                                                <button @click="testDL">点击</button>
                                            `;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    list: [],
                                                },
                                                mounted: function () {
                                                },
                                                methods: {
                                                    testRD: async function () {
                                                        let jFile = document.getElementById('jFile');
                                                        let data = await jerp.sheet.read(jFile.files[0], [{
                                                            name: '测试1',
                                                            index: 1
                                                        }, {
                                                            name: '测试2',
                                                            index: 2
                                                        }, {
                                                            name: '测试3',
                                                            index: 3
                                                        }]);
                                                        console.log(data);
                                                    },
                                                    testDL: function () {
                                                        jerp.sheet.download([[1, 2, 3], ['test1', 'test2', 'test3']]);
                                                    }
                                                },
                                            })
                                        }
                                    },
                                    { // 商品名称转编码
                                        name: '商品名称转编码',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;">
                                                                            <span>商品名称</span>
                                                                            <button @click="submit">提交</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_row">
                                                                            <textarea style="width: calc(100% - 0.6rem);height: 34.8rem;margin: 0.3rem;border-radius: 0.5rem;" v-model="titles"></textarea>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:3;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;">
                                                                            <span>商品编码</span>
                                                                            <button @click="daochu">导出</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row">
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.outerId}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "titles": "",
                                                    // "expressNos": "",
                                                    // "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    list: [], // 选中的商品列表
                                                },
                                                methods: {
                                                    submit: async function () {
                                                        let titles = jerp.strProcessing(this.titles).split(',');
                                                        let list = [];
                                                        titles.map(v => {
                                                            if (v != "") {
                                                                list.push({
                                                                    title: v,
                                                                    outerId: jerp.title2outerId(v)
                                                                });
                                                            }
                                                        });
                                                        this.list = list;
                                                    },
                                                    daochu: function () {
                                                        // let list = this.list.filter(v => { console.log(v.code, "_isSelected: ", v.isSelected, v); return v.isSelected });
                                                        // console.log('list:', list);
                                                        let data = [['商品名称', '商品编码']], dataStr = '';
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            // dataStr += list[i].code + '\n';
                                                            data.push([this.list[i].title, this.list[i].outerId]);
                                                        }
                                                        if (data.length > 0 || dataStr.length > 0) {
                                                            // jerp.copy(dataStr);
                                                            jerp.sheet.export(data, '商品转编码导出');
                                                        } else {
                                                            jerp.pxmu.toast('请勾选需要导出的数据！');
                                                        }
                                                    },
                                                },
                                            })
                                        }
                                    },
                                    { // 外购转单
                                        name: '外购转单',
                                        subName: '',
                                        active: false,
                                        status: false,
                                        role: ['何一洲'],
                                        init: function () {
                                            document.getElementById('jerpContent').innerHTML = `
                                            <div id="cwt">
                                                <div class="cwt_main" style="flex: 10; background: none; display: flex; border: none;overflow:hidden;">
                                                    <div class="cwt_inner" style="background: none;flex-flow: inherit;">
                                                        <div class="cwt_inner_left" style="flex:1;background: #ebebeb;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jTable_col" style="flex: 1;">
                                                                            <span>历史记录</span>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_row">

                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="cwt_inner_right" style="flex:2;background: #ebebeb;margin-left: 0.25rem;border-radius: 0.5rem;overflow: hidden auto;border: 0.15rem solid #cfcfcf;">
                                                            <div class="jTable">
                                                                <div class="jTable_title">
                                                                    <div class="jTable_row">
                                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                                            <span>快递：</span>
                                                                            <select style="width: 8rem;" v-model="express">
                                                                                <option value="" disabled="true" selected="true">请选择快递</option>
                                                                                <option v-for="item in expressList" :value="item.id">{{item.name}}</option>
                                                                            </select>
                                                                        </div>
                                                                        <div class="jerpCol" style="margin-left: 1rem;">
                                                                            <span>标签：</span>
                                                                            <select style="width: 8rem;" v-model="label">
                                                                                <option value="" disabled="true" selected="true">请选择标签</option>
                                                                                <option v-for="item in labelList" :value="item.id">{{item.tagName}}</option>
                                                                            </select>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="jTable_content">
                                                                    <div class="jTable_content_c">
                                                                        <div class="jTable_content_row" v-for="(item,index) in list">
                                                                            <div class="jTable_row">
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.title}}</span></div>
                                                                                <div class="jTable_col" style="flex: 1;"><span>{{item.outerId}}</span></div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>`;
                                            subVue = new Vue({
                                                el: "#jerpContent",
                                                data: {
                                                    "titles": "",
                                                    // "expressNos": "",
                                                    // "userName": jerp.jerpSetting.userInfos[jerp.jerpSetting.currentUser].userName,
                                                    "express": "",
                                                    "expressList": [],
                                                    "label": "",
                                                    "labelList": [],
                                                    list: [], // 选中的商品列表
                                                },
                                                mounted: async function () {
                                                    let tagList = [],
                                                        tagDatas = await jerp.getData({
                                                            url: '/trade/tag/list',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            "api_name": "trade_tag_list",
                                                            "kind": 0
                                                        });
                                                    // console.log(tagDatas);
                                                    if (tagDatas.length > 0) {
                                                        for (let i = 0; i < tagDatas.length; i++) {
                                                            // console.log(tagDatas[i].type);
                                                            if (tagDatas[i].type == 0) {
                                                                tagList.push(tagDatas[i]);
                                                                if (tagDatas[i].tagName.includes("发货")) {
                                                                    self.label = tagDatas[i].id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.labelList = tagList;


                                                    let expressList = [],
                                                        express = await jerp.getData({
                                                            url: '/pt/logistics/company/list',
                                                            api_name: 'pt_logistics_company_list',
                                                            method: 'get',
                                                            return: 'data',
                                                        }, {
                                                            pageNo: 1,
                                                            pageSize: 200,
                                                            receiptSource: "sale_trade",
                                                        });

                                                    if (express.length == 0) {
                                                        express = await jerp.getData({
                                                            url: '/pt/expresstemplate/groupbyexpresssid/get',
                                                            method: 'post',
                                                            return: 'data',
                                                        }, {
                                                            api_name: "pt_expresstemplate_groupbyexpresssid_get",
                                                            filterJitx: 0,
                                                            useLogisticsCompany: false
                                                        }, true);
                                                        for (let i = 0; i < express.expressTemplates.length; i++) {
                                                            let t = express.expressTemplates[i],
                                                                id = t.id.toString(),
                                                                name = t.name;
                                                            if (t.liveStatus == 1) {
                                                                // console.log(t);
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    // "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": t.templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    } else {
                                                        // this.SystemVersion = 2;
                                                        for (let i = 0; i < express.length; i++) {
                                                            // console.log(express[i], express[i].templateVOList.length);
                                                            if (express[i].templateVOList.length > 0) {
                                                                let id = express[i].id.toString(),
                                                                    name = express[i].name;
                                                                expressList.push({
                                                                    "id": id,
                                                                    "name": name,
                                                                    "templateId": express[i].templateVOList[0].templateId,
                                                                    "templateType": express[i].templateVOList[0].templateType,
                                                                });
                                                                if (name.includes("极兔")) {
                                                                    this.express = id;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    this.expressList = expressList;
                                                },
                                                methods: {
                                                    submit: async function () {
                                                        let titles = jerp.strProcessing(this.titles).split(',');
                                                        let list = [];
                                                        titles.map(v => {
                                                            if (v != "") {
                                                                list.push({
                                                                    title: v,
                                                                    outerId: jerp.title2outerId(v)
                                                                });
                                                            }
                                                        });
                                                        this.list = list;

                                                        let expressList = [],
                                                            express = await jerp.getData({
                                                                url: '/pt/logistics/company/list',
                                                                api_name: 'pt_logistics_company_list',
                                                                method: 'get',
                                                                return: 'data',
                                                            }, {
                                                                pageNo: 1,
                                                                pageSize: 200,
                                                                receiptSource: "sale_trade",
                                                            });

                                                        if (express.length == 0) {
                                                            express = await jerp.getData({
                                                                url: '/pt/expresstemplate/groupbyexpresssid/get',
                                                                method: 'post',
                                                                return: 'data',
                                                            }, {
                                                                api_name: "pt_expresstemplate_groupbyexpresssid_get",
                                                                filterJitx: 0,
                                                                useLogisticsCompany: false
                                                            }, true);
                                                            for (let i = 0; i < express.expressTemplates.length; i++) {
                                                                let t = express.expressTemplates[i],
                                                                    id = t.id.toString(),
                                                                    name = t.name;
                                                                if (t.liveStatus == 1) {
                                                                    // console.log(t);
                                                                    expressList.push({
                                                                        "id": id,
                                                                        "name": name,
                                                                        // "templateId": express[i].templateVOList[0].templateId,
                                                                        "templateType": t.templateType,
                                                                    });
                                                                    if (name.includes("极兔")) {
                                                                        this.express = id;
                                                                    }
                                                                }
                                                            }
                                                        } else {
                                                            this.SystemVersion = 2;
                                                            for (let i = 0; i < express.length; i++) {
                                                                // console.log(express[i], express[i].templateVOList.length);
                                                                if (express[i].templateVOList.length > 0) {
                                                                    let id = express[i].id.toString(),
                                                                        name = express[i].name;
                                                                    expressList.push({
                                                                        "id": id,
                                                                        "name": name,
                                                                        "templateId": express[i].templateVOList[0].templateId,
                                                                        "templateType": express[i].templateVOList[0].templateType,
                                                                    });
                                                                    if (name.includes("极兔")) {
                                                                        this.express = id;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        this.expressList = expressList;
                                                    },
                                                    daochu: function () {
                                                        // let list = this.list.filter(v => { console.log(v.code, "_isSelected: ", v.isSelected, v); return v.isSelected });
                                                        // console.log('list:', list);
                                                        let data = [['商品名称', '商品编码']], dataStr = '';
                                                        for (let i = 0; i < this.list.length; i++) {
                                                            // dataStr += list[i].code + '\n';
                                                            data.push([this.list[i].title, this.list[i].outerId]);
                                                        }
                                                        if (data.length > 0 || dataStr.length > 0) {
                                                            // jerp.copy(dataStr);
                                                            jerp.sheet.export(data, '商品转编码导出');
                                                        } else {
                                                            jerp.pxmu.toast('请勾选需要导出的数据！');
                                                        }
                                                    },
                                                },
                                            })
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    { // 备忘录
                        id: 'note',
                        name: '备忘录',
                        active: false,
                        status: false,
                        role: [],
                        openTag: 'note',
                    }
                ],
                pxmu: { // pxmu组件
                    showload: function (msg = '正在加载...') {
                        pxmu.loading({
                            msg: msg, //loading信息 为空时不显示文本
                            // time: 2500, //停留时间 
                            bg: 'rgba(0, 0, 0, 0.65)', //背景色
                            color: '#fff', //文字颜色
                            animation: 'fade', //动画名 详见动画文档
                            close: false, // 自动关闭 为false时可在业务完成后调用 pxmu.closeload();手动关闭
                            inscroll: false, //模态 不可点击和滚动
                            inscrollbg: 'rgba(0, 0, 0, 0.45)',//自定义遮罩层颜色 为空不显示遮罩层
                        });
                    },
                    closeload: function (msg = '', time = 2500) {
                        pxmu.closeload();
                        if (msg != '') {
                            jerp.pxmu.toast(msg, time);
                        }
                    },
                    toast: function (msg = '操作成功', time = 2500) {
                        pxmu.toast({
                            msg: msg, //内容 不能为空
                            time: time, //停留时间 默认2500毫秒
                            bg: 'rgba(0, 0, 0, 0.86)', //背景颜色 默认黑色
                            color: '#fff', //文字颜色 默认白色
                            location: 'center',//居中center 顶部top 底部bottom默认
                            animation: 'fade', //显示的动画 默认fade 动画支持详见动画文档
                            type: 'wap', //默认wap样式 可选参数：pc 入参pc时
                            status: '', //可选参数 success成功 warn警告 error错误 仅在type=pc时候生效，wap时可通过自定义bg、color改变样式
                        });
                    },
                    success: function (msg = '成功') {
                        pxmu.success({
                            msg: msg, //loading信息 为空时不显示文本
                            time: 2500, //停留时间 
                            bg: 'rgba(0, 0, 0, 0.65)', //背景色
                            color: '#fff', //文字颜色
                            animation: 'fade', //动画名 详见动画文档
                            close: true, // 自动关闭 为false时可在业务完成后调用 pxmu.closeload();手动关闭
                            // inscroll: false, //模态 不可点击和滚动
                            // inscrollbg: 'rgba(0, 0, 0, 0.45)',//自定义遮罩层颜色 为空不显示遮罩层
                        });
                    },
                    fail: function (msg = '失败') {
                        pxmu.fail({
                            msg: msg, //loading信息 为空时不显示文本
                            time: 2500, //停留时间 
                            bg: 'rgba(0, 0, 0, 0.65)', //背景色
                            color: '#fff', //文字颜色
                            animation: 'fade', //动画名 详见动画文档
                            close: true, // 自动关闭 为false时可在业务完成后调用 pxmu.closeload();手动关闭
                            // inscroll: false, //模态 不可点击和滚动
                            // inscrollbg: 'rgba(0, 0, 0, 0.45)',//自定义遮罩层颜色 为空不显示遮罩层
                        });
                    },
                    copy: function (content, msg = "复制成功") {
                        pxmu.copy(content);
                        jerp.pxmu.toast(msg);
                    },
                    dialog: function (msg) {
                        pxmu.diaglog({
                            title: {
                                text: '提示', //标题文本
                                // color: '#000', //标题颜色
                                // fontsize: 20, //字体大小
                                // fontweight: 'bold', //是否加粗 bold加粗 normal不加粗
                                // center: false //true为居中显示 false为不居中显示
                            },
                            content: {
                                text: msg, //文本内容 为空时不显示
                                // color: '#444', //文本颜色
                                // fontsize: 14, //文本字体大小
                                // fontweight: 'normal', //是否加粗 bold加粗 normal不加粗
                            },
                            btn: {
                                left: {
                                    text: '取消', //左侧按钮文本内容
                                    // color: '#f50', //左侧按钮颜色
                                    // fontsize: 16, //左侧按钮字体大小
                                    // fontweight: 'bold', //左侧按钮是否加粗 bold加粗 normal不加粗
                                    // bg: '#fff', //左侧按钮背景色
                                    // solid: 1, //左侧按钮描边粗细
                                    // solidcolor: '#f50', //左侧按钮描边颜色
                                },
                                right: {
                                    text: '确定', //右侧按钮文本内容
                                    // color: '#fff', //右侧按钮文本颜色
                                    // fontsize: 16, //右侧按钮文本大小
                                    // fontweight: 'bold', //右侧按钮是否加粗 bold加粗 normal不加粗
                                    // bg: '#f50', //右侧按钮字体颜色
                                    // solid: 1, //右侧按钮描边
                                    // solidcolor: '#f50', //右侧按钮描边颜色
                                }
                            },
                            congif: {
                                // animation: 'slidedeg', //自定义动画 动画名详见动画文档
                                btncount: false, //true时显示一个按钮 默认true 2个按钮
                            }
                        }).then(function (res) {
                            if (res.btn == 'right') {
                                //点击了右侧按钮
                            } else {
                                //点击了左侧按钮
                            }
                        });
                    }
                },
                priview: { // 大图预览
                    src: '',
                    delay: 500,
                    wait: 0,
                    x: 0,
                    y: 0,
                    width: 0,
                    height: 0,
                    focusA: false,
                    focusB: false,
                    scale: 1,
                },
                math: { // +-*/，避免js数学错误
                    jia: function (a, b) {
                        let t = math.format(math.add(math.bignumber(a), math.bignumber(b)));
                        return parseFloat(t);
                    },
                    jian: function (a, b) {
                        let t = math.format(math.subtract(math.bignumber(a), math.bignumber(b)));
                        return parseFloat(t);
                    },
                    chen: function (a, b) {
                        let t = math.format(math.multiply(math.bignumber(a), math.bignumber(b)));
                        return parseFloat(t);
                    },
                    chu: function (a, b) {
                        let t = math.format(math.divide(math.bignumber(a), math.bignumber(b)));
                        return parseFloat(t);
                    },
                },
                sheet: {
                    /**
                     * @param {*} file this.files[0]
                     * @param {*} cols [{name,index}]
                     * @returns data:{}
                     */
                    import: async function (file, cols = []) {
                        return new Promise((resolve, reject) => {
                            if (cols.length == 0) {
                                reject('请选择需要导入的列！');
                            }

                            let reader = new FileReader();
                            reader.onload = function (e) {
                                resolve(e);
                            };
                            reader.readAsArrayBuffer(file);
                        }).then(async e => {
                            // 单元格的描述
                            // s:合并单元格左上格 e:合并单元格右下格
                            // c:列序号（从0开始） r:行序号（从0开始）
                            // XLSX.utils.decode_cell("A2");                        // 得到{r:1,c:0}
                            // XLSX.utils.encode_cell({r:1,c:0});                   // 得到A2
                            // XLSX.utils.decode_range("A1:D3");                    // 得到{s:{c:0,r:0},e:{c:3,r2}}
                            // XLSX.utils.encode_range({s:{c:0,r:0},e:{c:3,r2}});   // 得到"A1:D3"
                            // console.log(worksheet['A1']);                        // 输出A1格数据
                            // console.log(worksheet['!merges']);                   // 输出所有合并单元格数据
                            // console.log(worksheet['!ref']);                      // 输出当前工作表使用的范围

                            // jerp.sheet.parse(e.target.result);
                            const workbook = XLSX.read(e.target.result);
                            // console.log('workbook: ', workbook);
                            var first_sheet_name = workbook.SheetNames[0];
                            const worksheet = workbook.Sheets[first_sheet_name];

                            let data = [], r = 1;
                            while (1) {
                                let rowData = {}, rNum = 0;
                                for (let i = 0; i < cols.length; i++) {
                                    let c = cols[i].index - 1;
                                    let v = worksheet[XLSX.utils.encode_cell({ "r": r, "c": c })];
                                    rowData[cols[i].name] = !v ? '' : v.v;
                                    if (v != undefined) { rNum++; }
                                }
                                if (rNum == 0) { break; }
                                // console.log(rowData);
                                data.push(rowData);
                                r++;
                                // await jerp.sleep(100);
                            }
                            // console.log(data);
                            // resolve({ "suc": true, "data": data });
                            return { "suc": true, "data": data };
                        }).catch(msg => {
                            return { "suc": false, "msg": msg };
                        });
                    },
                    /**
                     * @param {*} data [[],[],[],[]] 每一个[]是一行数据
                     * @param {*} title 导出文件名称
                     */
                    export: function (data, title) {
                        const workbook = XLSX.utils.book_new();
                        const worksheet = XLSX.utils.aoa_to_sheet(data); // 从二维数组新建工作表
                        // XLSX.utils.sheet_add_aoa(worksheet,[['Naisu']],{origin:'C2'}); // 向单元格写入数据
                        XLSX.utils.book_append_sheet(workbook, worksheet, 'sheet1');
                        XLSX.writeFileXLSX(workbook, (title != undefined ? title : '导出数据') + "_" + jerp.getFormatDate(new Date(), 'yyyyMMdd') + '.xlsx');
                    }
                }
            },
            created: function () {
                let self = this;
                // 初始化时，做一下账号判定
                $.ajax({
                    url: location.origin + '/user/info?api_name=user_info',
                    method: 'get',
                    dataType: 'json',
                    async: false,
                    data: {
                        api_name: 'user_info'
                    },
                    success: function (e) {
                        if (e && e.clueId && e.result == 1) {
                            // console.log('用户信息： ', e.data);
                            self.jerpSetting.currentUser = e.data.id;
                            let localui = window.localStorage.getItem('jerpUserInfos');
                            if (localui === undefined || localui === null) {
                                self.jerpSetting.userInfos = {};
                            } else {
                                self.jerpSetting.userInfos = JSON.parse(localui);
                            }
                            // console.log("local_userInfos: ", self.jerpSetting.userInfos);
                            if (self.jerpSetting.userInfos[self.jerpSetting.currentUser] === undefined || self.jerpSetting.userInfos[self.jerpSetting.currentUser] === null) {
                                self.jerpSetting.userInfos[self.jerpSetting.currentUser] = {
                                    userId: e.data.id,
                                    userName: e.data.account,
                                    companyId: e.data.companyId,
                                    note: {
                                        clientX: 0,
                                        clientY: 0,
                                        content: '',
                                    }
                                }
                            }
                            self.jerpSetting.userInfos[self.jerpSetting.currentUser].bindShops = e.data.bindShops;
                            self.jerpSetting.userInfos[self.jerpSetting.currentUser].warehouses = e.data.warehouses;
                            self.jerpSetting.note.clientX = self.jerpSetting.userInfos[self.jerpSetting.currentUser].note.clientX;
                            self.jerpSetting.note.clientY = self.jerpSetting.userInfos[self.jerpSetting.currentUser].note.clientY;
                        }
                    },
                    error: function (e) {
                        console.log("error", e);
                    }
                });
                // 获取三级省市区
                self.getPca3level();

                // 缓存初始化，主要用来把老的缓存合并到新的缓存中
                let noteStorage = window.localStorage.getItem(this.jerpSetting.currentUser + 'note');
                if (noteStorage !== undefined && noteStorage !== null) {
                    this.jerpSetting.userInfos[this.jerpSetting.currentUser].note.content = noteStorage;
                    localStorage.removeItem(this.jerpSetting.currentUser + 'note');
                    this.updateUserInfo();
                }
                let clientXStorage = window.localStorage.getItem(this.jerpSetting.currentUser + 'noteX');
                if (clientXStorage !== undefined && clientXStorage !== null) {
                    this.jerpSetting.userInfos[this.jerpSetting.currentUser].note.clientX = clientXStorage && clientXStorage != "" ? parseFloat(clientXStorage) : 0;
                    localStorage.removeItem(this.jerpSetting.currentUser + 'noteX');
                    this.updateUserInfo();
                }
                let clientYStorage = window.localStorage.getItem(this.jerpSetting.currentUser + 'noteY');
                if (clientYStorage !== undefined && clientYStorage !== null) {
                    this.jerpSetting.userInfos[this.jerpSetting.currentUser].note.clientY = clientYStorage && clientYStorage != "" ? parseFloat(clientYStorage) : 0;
                    localStorage.removeItem(this.jerpSetting.currentUser + 'noteY');
                    this.updateUserInfo();
                }
            },
            mounted: function () {
                // console.log('mounted');
                let self = this;
                // 根据权限设置菜单显示状态
                self.setMenuStatus(self.jerpData, self.jerpSetting.userInfos[self.jerpSetting.currentUser].userName);

                window.addEventListener('wheel', async function (e) {
                    e.stopPropagation();
                    if (jerp.priview.focusA || jerp.priview.focusB) {
                        // console.log(e.deltaY);
                        if (e.deltaY > 0) { // 缩小
                            // console.log("缩小");
                            jerp.priview.scale -= 0.05;
                        }
                        else if (e.deltaY < 0) { // 放大
                            // console.log("放大");
                            jerp.priview.scale += 0.05;
                        }
                    }
                });
                window.addEventListener('mouseover', async function (e) {
                    e.stopPropagation();
                    /** 预览图重写*/
                    if (e.target.classList.contains('hover-show')) {
                        let $p = jerp.parentIs(e, 'class', 'order-img-item');
                        if ($p) {
                            // await jerp.sleep(0);
                            if ($p.children && $p.children.length > 1) {
                                if ($p.children[1].childre && $p.children[1].childre.legnth > 0) {
                                    let $img = $p.children[1].children[0];
                                    jerp.priview.src = $img.src;
                                    jerp.priview.x = e.x - e.offsetX;
                                    jerp.priview.y = e.y - e.offsetY;
                                }
                            }
                        }
                    }
                    /* 采购单附件显示 */
                    if (e.target.classList.contains('proof-list-item')) {
                        // await jerp.sleep(0);
                        let hrefList = e.target.dataset.href.split('.'),
                            exList = ['png', 'PNG', 'jpg', 'JPG', 'jpeg', 'JPEG', 'gif', 'GIF', 'webp', 'WEBP', 'heic', 'HEIC', 'tiff', 'TIFF'],
                            extension = hrefList[hrefList.length - 1];
                        if (exList.indexOf(extension) > -1) {
                            jerp.priview.src = e.target.dataset.href;
                            jerp.priview.x = e.x - e.offsetX;
                            jerp.priview.y = e.y - e.offsetY;
                        }
                    }
                    if (e.target.classList.contains('jerpPriviewImg')) {
                        jerp.priview.focusB = true;
                        // console.log("鼠标移动到图片上了: ", jerp.priview.focusB);
                    }
                    /** 订单页面 内部单号over显示日志 */
                    if (e.target.nodeName == 'A') {
                        if (e.target.dataset.name == 'show_detail_dialog' && jerp.domIs(e.target, 'trackname', 'Trade_cell_NeiBuDanHao')) { // 订单界面-短号
                            let p = self.parentIs(e, 'class', 'short-id');
                            if (p) {
                                let c = null,
                                    shortId = e.target.innerText;
                                if (self.jerpSetting.shortIdOver != shortId) {
                                    c = self.childrenIs(p, 'trackname', 'Trade_cell_RiZhi');
                                    self.jerpSetting.shortIdOver = shortId;
                                    c.click();
                                }
                            }
                        }
                    }
                    if (e.target.nodeName == 'SPAN') {
                        if (e.target.dataset.name == 'showLog' && jerp.domIs(e.target, 'trackname', 'Trade_cell_RiZhi')) { // 订单界面-日志
                            let p = self.parentIs(e, 'class', 'short-id');
                            if (p) {
                                let c = null;
                                c = self.childrenIs(p, 'trackname', 'Trade_cell_NeiBuDanHao');
                                if (c) {
                                    shortId = c.innerText;
                                    if (self.jerpSetting.shortIdOver != shortId) {
                                        self.jerpSetting.shortIdOver = shortId;
                                        e.target.click();
                                    }
                                }
                            }
                        }
                    }
                });
                document.getElementById('jerpPriviewImg').addEventListener('load', function () {
                    let $priview = document.getElementById('jerpPriviewImg');
                    let nw = Math.floor($priview.naturalWidth),
                        nh = Math.floor($priview.naturalHeight),
                        bl = nw / nh;

                    if (nw > window.innerWidth * 0.6) {
                        nw = window.innerWidth * 0.6;
                    } else {
                        // 如果宽度太小了
                        nw = window.innerWidth * 0.4;
                    }
                    if (nh > window.innerHeight * 0.8) {
                        nh = window.innerHeight * 0.8;
                    } else {
                        // 如果高度太小了
                        nh = window.innerHeight * 0.6;
                    }
                    let w = 0, h = 0;
                    if (bl > 1) { // 横向
                        w = nw;
                        h = w / bl;
                        if (h > nh) {
                            h = nh;
                            w = bl * h;
                        }
                    } else { // 竖向
                        h = nh;
                        w = bl * h;
                    }
                    jerp.priview.width = Math.floor(w);
                    jerp.priview.height = Math.floor(h);
                    if (w > window.innerWidth - jerp.priview.x) {
                        jerp.priview.x -= w - (window.innerWidth - jerp.priview.x);
                    }
                    if (h > window.innerHeight - jerp.priview.y) {
                        jerp.priview.y -= h - (window.innerHeight - jerp.priview.y);
                    }
                    jerp.priview.focusA = true;
                    jerp.priview.scale = 1;
                    // console.log("图片加载了: ", jerp.priview.focusA);
                });
                window.addEventListener('mouseout', async function (e) {
                    let cl = e.target.classList
                    if (cl.contains('jerpPriviewImg')) {
                        jerp.priview.focusA = false;
                        jerp.priview.focusB = false;
                        jerp.priview.src = '';
                        // console.log('离开了预览图');
                    } else if (
                        (cl.contains('proof-list-item')) ||
                        (cl.contains('hover-show') && jerp.parentIs(e, 'class', 'order-img-item'))
                    ) {
                        // console.log(cl);
                        jerp.priview.focusA = false;
                    }
                });
                window.addEventListener('click', function (e) {
                    console.log("点击了");
                    if (e.target) {
                        // console.log(e);
                        // 交易，在非日志按钮点击，移除日志锁定（shortIdOver赋值为null）
                        if (!(e.target.nodeName == 'SPAN' && e.target.innerHTML.includes('日志'))) {
                            if (self.jerpSetting.shortIdOver != null) self.jerpSetting.shortIdOver = null;
                        }
                        // // 退货登记，点击“确认退货入仓”按钮
                        // if (self.parentIs(e, 'trackname', 'aftersale_fast_return_next_queRenTuiHuoRuCang')) {
                        //     self.aftersaleRN();
                        // }
                        let cl = e.target.classList;
                        console.log(cl ? cl : "没有cl");
                        if (cl && cl.contains('jerpPriviewImg')) {
                            jerp.priview.focusA = false;
                            jerp.priview.focusB = false;
                            jerp.priview.src = '';
                            // console.log('离开了预览图');
                        }
                    }
                });
                window.addEventListener('keydown', function (e) {
                    // console.log('keydown: ', e);
                    e = e || window.event;
                    if (e.keyCode == 13) {
                        // console.log('target: ', e.target);
                        // console.log('按下了回车');
                        // 退货登记，在快递单input按下回车
                        // console.log(e.target.id);
                        switch (e.target.id) {
                            case 'out_sid':
                            case 'tid': {
                                // console.log("是否退货登记：", location.href.includes('/aftersale/fast_return_next/'));
                                if (location.href.includes('/aftersale/fast_return_next/')) { // 退货登记页面
                                    self.aftersaleRN(e.target.id);
                                }
                                break;
                            }
                            default: {
                                break;
                            }
                        }
                    }
                });
                /** 退货登记：显示商品货位等信息 */
                if (location.href.includes('/aftersale/fast_return_next/')) {
                    self.jerpSetting.aftersaleRN.status = true;
                }
                window.onhashchange = e => {
                    if (e.newURL.includes('/aftersale/fast_return_next/')) {
                        self.jerpSetting.aftersaleRN.status = true;
                    } else {
                        self.jerpSetting.aftersaleRN.status = false;
                    }
                }

                // console.log("仓库列表：", this.jerpSetting.userInfos[this.jerpSetting.currentUser].warehouses);
                this.jerpSetting.aftersaleRN.warehouseList = this.jerpSetting.userInfos[this.jerpSetting.currentUser].warehouses;
                if (this.jerpSetting.aftersaleRN.warehouseList.length > 0) {
                    this.jerpSetting.aftersaleRN.warehouse = this.jerpSetting.aftersaleRN.warehouseList[0].id;
                }
            },
            computed: {
                winMenu: function () {
                    let datas = this.jerpData.filter(e => { return e.id == 'erpInterface' });
                    if (datas.length > 0) {
                        if (datas[0].status) {
                            return datas[0].child;
                        } else {
                            return [];
                        }
                    } else {
                        return [];
                    }
                },
                menuData: function () {
                    return this.initMenuStatus();
                }
            },
            methods: {
                setCodeName: function (stock) {
                    if (stock.includes('Z-S')) {
                        stock = 'Z-丝扣类';
                    }
                    if (stock.includes('Z-W')) {
                        stock = 'Z-卫生类';
                    }
                    if (stock.includes('Z-F')) {
                        stock = 'Z-阀门类';
                    }
                    if (stock.includes('Z-C')) {
                        stock = 'Z-冲压类';
                    }
                    if (stock.includes('DT')) {
                        stock = stock + '（大厅）';
                    }
                    if (stock.includes('QF')) {
                        stock = stock + '（球阀区）';
                    }
                    if (stock.includes('LM')) {
                        stock = stock + '（办公室）';
                    }
                    if (stock.includes('TW')) { // 台湾区
                        stock = stock + '（过道备货区）';
                    }
                    return stock;
                },
                getPca3level: async function () { // 获取省市区三级联动
                    let pca3level = await this.getData({
                        url: '/trade/base/address/all?level=3',
                        method: 'post',
                        return: 'data',
                    }, {
                        api_name: 'trade_base_address_all?level=3',
                    });
                    let pca3level_filter = {};
                    for (let key_a in pca3level) {
                        let obj_a = pca3level[key_a], value_a = obj_a[0], id_a = obj_a[1];
                        if (id_a === "1") {
                            pca3level_filter[value_a] = {};
                            for (let key_b in pca3level) {
                                let obj_b = pca3level[key_b], value_b = obj_b[0], id_b = obj_b[1];
                                if (id_b == key_a) {
                                    pca3level_filter[value_a][value_b] = [];
                                    for (let key_c in pca3level) {
                                        let obj_c = pca3level[key_c], value_c = obj_c[0], id_c = obj_c[1];
                                        if (id_c == key_b) {
                                            pca3level_filter[value_a][value_b].push(value_c);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // console.log(pca3level_filter);
                    this.jerpSetting.pca3level = pca3level_filter;
                },
                /** ↓↓↓菜单功能↓↓↓ */
                initMenuStatus: function (menu = this.jerpData, list = []) {
                    let self = this;
                    if (menu && menu.length > 0) {
                        for (let i = 0; i < menu.length; i++) {
                            let m = menu[i];
                            if (m.child) {

                            }
                            list.push(m);
                        }
                    }
                },
                setMenuStatus: function (menu, account) { // 根据权限，设置菜单的展示
                    let self = this, showNum = 0;
                    if (menu && menu.length > 0) {
                        for (let i = 0; i < menu.length; i++) {
                            let m = menu[i], showTabNum = 0;
                            // console.log(m.role,account,m.role.indexOf(account));
                            if (!m.role || m.role.length == 0 || m.role.indexOf(account) > -1) {
                                //  || (!datas[0].child && datas[0].role.length == 0)
                                if (!m.child) {
                                    m.status = true;
                                    showNum++;
                                } else if (m.child && m.child.length > 0) {
                                    showTabNum = self.setMenuStatus(m.child, account);
                                    if (showTabNum > 0) {
                                        m.status = true;
                                        showNum++;
                                    }
                                }
                            } else {
                                m.status = false;
                            }
                            // console.log(m.name, 'role: ', m.role, m.status);
                        }
                    }
                    return showNum;
                },
                open: function (t) { // 打开一级窗口
                    // console.log(t);
                    switch (t) {
                        case 'window': {
                            this.showWindow = true;
                            break;
                        }
                        case 'note': {
                            this.showNote = true;
                            break;
                        }
                        default: {
                            // this.showWindow = false;
                            // this.showNote = false;
                            break;
                        }
                    }
                },
                close: function (t) { // 关闭一级窗口
                    switch (t) {
                        case 'window': {
                            this.showWindow = false;
                            break;
                        }
                        case 'note': {
                            this.showNote = false;
                            break;
                        }
                        default: {
                            this.showWindow = false;
                            this.showNote = false;
                            break;
                        }
                    }
                },
                showSub: function (item) { // 展开菜单子窗口
                    this.hideAllSub();
                    if (item && (!item.child || (item.child && Object.keys(item.child).length > 0))) {
                        item.active = true;
                    }
                    if (!item.child && item.init) {
                        item.init();
                    }
                },
                hideAllSub: function () {  // 关闭菜单子窗口
                    // item.active = false;
                    for (let i in this.winMenu) {
                        let m = this.winMenu[i];
                        m.active = false;
                    }
                },
                openTab: function (subItem) { // 打开子功能模块
                    // console.log("open: ", subItem);
                    if (subVue) {
                        subVue.$destroy();
                    }
                    this.showDialog = false;

                    // this.winTitle = subItem.name;
                    // this.winSubtitle = '';
                    // created: function () {
                    this.winTitle.title = subItem.name;
                    this.winTitle.winSubtitle = subItem.subName;
                    this.winTitle.selected = null;
                    this.winTitle.get = 0;
                    this.winTitle.total = 0;
                    this.winTitle.getTime = '';
                    this.winTitle.otherContent = '';
                    // },
                    // this.hideAllSub();
                    subItem.init();
                },
                /** ↓↓↓便签功能↓↓↓ */
                updateUserInfo: function () { // 更新便签缓存
                    // console.log('update_userInofs: ', jerp.jerpSetting.userInfos);
                    localStorage.setItem('jerpUserInfos', JSON.stringify(jerp.jerpSetting.userInfos));
                },
                notemousedown: function (e) { // 便签窗口移动
                    let self = this,
                        mouseX = parseFloat(e.clientX),
                        mouseY = parseFloat(e.clientY),
                        box = document.getElementById('jerpNote');
                    document.onmousemove = function (e) {
                        let targetX = parseFloat(e.clientX),
                            targetY = parseFloat(e.clientY);
                        self.jerpSetting.userInfos[self.jerpSetting.currentUser].note.clientX += targetX - mouseX;
                        self.jerpSetting.note.clientX += targetX - mouseX;
                        self.jerpSetting.userInfos[self.jerpSetting.currentUser].note.clientY += targetY - mouseY;
                        self.jerpSetting.note.clientY += targetY - mouseY;
                        mouseX = targetX;
                        mouseY = targetY;
                    }
                    document.onmouseup = function () {
                        document.onmousemove = null;
                        box.onmouseup = null;
                        self.updateUserInfo();
                    }
                },
                /** ↓↓↓查找dom↓↓↓ */
                domIs: function (e, type, value) {
                    let f = false;
                    switch (type) {
                        case 'class': {
                            f = e.classList && e.classList.length > 0 ? e.classList.contains(value) : false;
                            break;
                        }
                        case 'id': {
                            break;
                        }
                        case 'nodeName': {
                            f = e.nodeName == value ? true : false;
                            break;
                        }
                        case 'trackname': {
                            let ab = e.attributes;
                            if (ab && Object.keys(ab).length > 0) {
                                if (ab.trackname && ab.trackname.value == value) {
                                    f = true;
                                }
                            }
                            break;
                        }
                    }
                    return f;
                },
                // 向上查找指定id或class
                parentIs: function (e, type, name) {
                    let self = this,
                        f = false,
                        _e = e.target ? e.target : e,
                        p = _e.parentNode;
                    if (self.domIs(p, type, name)) {
                        return _e;
                    } else {
                        for (let i = 0; i < 10; i++) {
                            if (!p) break;
                            if (self.domIs(p, type, name)) {
                                return p;
                            } else {
                                p = p.parentNode
                            }
                        }
                    }
                    return false;
                },
                // 向下查找指定内容
                childrenIs: function (e, type, name, num = 1) {
                    let self = this,
                        f = false,
                        _e = e.target ? e.target : e;
                    // if (num == 1) console.log('=================第' + num + '层');
                    // console.dir(_e);
                    if (self.domIs(_e, type, name)) {
                        return _e;
                    } else {
                        if (_e.children.length > 0) {
                            for (let i = 0; i < _e.children.length; i++) {
                                // console.log('=================第' + (num + 1) + '层');
                                // console.log('index: ', i);
                                let c = self.childrenIs(_e.children[i], type, name, num + 1);
                                if (c) {
                                    return c;
                                }
                            }
                        }
                    }
                    return false;
                },
                /** ↓↓↓售后退货货位小窗口↓↓↓ */
                aftersaleRN: async function (type, times = 0) {
                    if (times >= 5) {
                        return;
                    }
                    await jerp.sleep(1000);
                    let self = this,
                        flag = true,
                        $target = document.getElementById(type);

                    let _arn = self.jerpSetting.aftersaleRN;
                    _arn.sysStatus = '';
                    _arn.isPicked = '';
                    _arn.list = [];
                    // console.log("type: ", type, $target == undefined || $target == null);
                    if ($target == undefined || $target == null) {
                        flag = false;
                    } else {
                        // 不勾选或只查询订单
                        let rs = document.getElementsByClassName('z-table-row');
                        // 勾选“查询订单和售后工单”
                        let ts = document.getElementsByClassName('order-list-item');
                        console.log("rs: ", rs.length, " ts: ", ts.length);
                        if (rs.length == 0 && ts.length == 0) {
                            // console.log("没找到！");
                            flag = false;
                        } else {
                            let tids = [], shortIds = [], goodsList = [],
                                postData = {
                                    api_name: 'trade_search',
                                    useHasNext: 1,
                                    queryId: 8,
                                    order: 'desc',
                                    pageNo: 1,
                                    pageSize: 50,
                                    domCache: 0,
                                    // tid: tid,
                                    timeType: 'pay_time',
                                    key: 'itemTitle',
                                    highlight: false,
                                    _t: new Date().getTime(),
                                    field: 'pay_time',
                                    needOrder: 0,
                                    useCompress: 1,
                                    minutesAfterPaidOrderAreNotDisplayed: 0,
                                };
                            if (rs.length > 0) {
                                // console.log("处理rs");
                                let o = rs[0], oc = o.children[0];
                                for (let i = 0; i < oc.children.length; i++) {
                                    if (oc.children[i].innerText.includes('平台订单号')) {
                                        tids.push(oc.children[i + 1].innerText);
                                    } else if (oc.children[i].innerText.includes('内部订单号')) {
                                        shortIds.push(oc.children[i + 1].innerText);
                                    }
                                }

                                // 商品信息
                                for (let i = 0; i < rs.length; i++) {
                                    let g = rs[i];
                                    if (!g.className.includes('z-table__expanded-cell')) {
                                        let gc = g.children[5];
                                        // console.log('gc: ', gc);
                                        if (gc == undefined || gc == null) {
                                            // flag = false;
                                            // break;
                                        } else {
                                            let sid = gc.children[0].children[0].children[0].innerText.replace(/\ +/g, "");
                                            if (gc.className.indexOf('j_isGetInfo') > -1) {
                                                // console.log(sid, "已经有了");
                                            } else {
                                                gc.classList.add('j_isGetInfo');
                                                // goodsList.push(sid);
                                                let codes = [];
                                                let goods = await jerp.getGoodsCode(sid, this.jerpSetting.aftersaleRN.warehouse);
                                                if (goods && goods.length > 0) {
                                                    goods.map(v => codes.push(v.code));
                                                };
                                                console.log(sid, '的货位: ', codes);
                                                gc.insertAdjacentHTML('afterend', `
                                                    <div class="z-table-row-cell" style="width: 160px; min-width: 160px; background: rgb(227, 243, 205);">
                                                        <div class="cell">
                                                            <div data-v-646827ee="" class="business-code">
                                                                <p data-v-646827ee="" class="font-size-18">${codes.toString()}</p>
                                                            </div>
                                                        </div>
                                                    </div>`);
                                            }
                                        }
                                    }
                                }
                            }
                            else if (ts.length > 0) {
                                // console.log("处理ts");
                                for (let i = 0; i < ts.length; i++) {
                                    // 获取单号
                                    let ti = ts[i].getElementsByClassName('order-list-info-wrap');
                                    for (let j = 0; j < ti.length; j++) {
                                        for (let z = 0; z < ti[j].children.length; z++) {
                                            let tid = ti[j].children[z];
                                            if (tid.children[0].innerText.includes('平台订单号')) {
                                                tids.push(tid.children[1].innerText);
                                                break;
                                            }
                                            else if (tid.children[0].innerText.includes('内部订单号')) {
                                                shortIds.push(tid.children[1].innerText);
                                                break;
                                            }
                                        }
                                    }
                                    // 修改表格标题 
                                    let tt = ts[i].getElementsByClassName('el-table__header');
                                    if (tt.length > 0) {
                                        let ttc = tt[0].children[0].children[4];// colgroup
                                        if (ttc.className.indexOf('j_isGetInfo') > -1) {
                                            flag = false;
                                        } else {
                                            ttc.classList.add('j_isGetInfo');
                                            ttc.insertAdjacentHTML('afterend', `<col name="el-table_2_column__1" width="156">`);
                                        }
                                        let ttd = tt[0].children[1].children[0].children[4];
                                        if (ttd.className.indexOf('j_isGetInfo') > -1) {
                                            flag = false;
                                        } else {
                                            ttd.classList.add('j_isGetInfo');
                                            ttd.insertAdjacentHTML('afterend',
                                                `<th colspan="1" rowspan="1" class="el-table_2_column__1 is-leaf">
                                                    <div class="cell">货位编码</div>
                                                </th>`);
                                        }
                                    }

                                    // 获取商品
                                    let tg = ts[i].getElementsByClassName('el-table__body');
                                    if (tg.length > 0) {
                                        let tgc = tg[0].children[0].children[4];// colgroup
                                        if (tgc.className.indexOf('j_isGetInfo') > -1) {
                                            flag = false;
                                        } else {
                                            tgc.classList.add('j_isGetInfo');
                                            tgc.insertAdjacentHTML('afterend', `<col name="el-el-table_1_column__1" width="156">`);
                                        }
                                        for (let j = 0; j < tg[0].children[1].children.length; j++) {
                                            let tgd = tg[0].children[1].children[j].children[4];
                                            if (tgd.className.indexOf('j_isGetInfo') > -1) {
                                                flag = false;
                                            } else {
                                                tgd.classList.add('j_isGetInfo');
                                                let codes = [],
                                                    sid = tgd.children[0].children[0].innerText,
                                                    goods = await jerp.getGoodsCode(sid, this.jerpSetting.aftersaleRN.warehouse);
                                                if (goods && goods.length > 0) {
                                                    goods.map(v => codes.push(v.code));
                                                };
                                                tgd.insertAdjacentHTML('afterend',
                                                    `<td rowspan="1" colspan="1" class="el-table_1_column__1">
                                                        <div class="cell">
                                                            <span>${codes.toString()}</span>
                                                        </div>
                                                    </td> `);
                                            }
                                        }
                                    }
                                }
                            }
                            if (tids.length > 0 != '') { postData = { ...postData, ...{ tid: tids[0] } } }
                            else if (shortIds.length > 0 != '') { postData = { ...postData, ...{ shortId: shortIds[0] } } } else { flag = false; }
                            // if (goodsList.length == 0) { flag = false; }
                            // console.log('flag: ', flag, 'tids: ', tids);
                            // console.log('shortIds: ', shortIds);
                            if (flag) {
                                // 订单信息
                                // 平台订单号：
                                let orderList = await jerp.getData({
                                    url: '/trade/search',
                                    method: 'post',
                                    return: 'data.list'
                                }, postData);
                                if (orderList.length > 0) {
                                    for (let o = 0; o < orderList.length; o++) {
                                        if (
                                            (tids.length > 0 && tids.filter(v => v === orderList[o].a).length > 0) ||
                                            (shortIds.length > 0 && shortIds.filter(v => v === orderList[o].shortId).length > 0)
                                        ) {
                                            let sid = orderList[o].b;
                                            // console.log('订单号: ', sid);
                                            let order = await jerp.getData({
                                                url: '/trade/detail',
                                                method: 'get',
                                                return: 'data'
                                            }, {
                                                api_name: 'trade_detail',
                                                sid: sid,
                                            });
                                            // console.log('日志: ',order.traces);
                                            let isPicked = false;
                                            for (let i = 0; i < order.traces.length; i++) {
                                                let t = order.traces[i];
                                                if (t.content.includes('扣减货位库存')) {
                                                    isPicked = true;
                                                    break;
                                                }
                                            }
                                            _arn.sysStatus = jerp.sysStatus[orderList[0].cl];
                                            _arn.isError = orderList[0].cl == 'CANCEL' || orderList[0].cl == 'CLOSED' ? true : false;
                                            _arn.isPicked = isPicked ? '已扣减' : '无扣减记录';
                                            // console.log(_arn);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // console.log("flag: ", flag);
                    if (!flag) {
                        self.aftersaleRN(type, ++times);
                    }
                },
                /** ↓↓↓其他自定义方法↓↓↓ */
                // 全局复制按钮
                copy: function (content, mes = '已复制') {
                    if (content != '') {
                        new ClipboardJS('#jerpFrame .copy', {
                            text: function () {
                                return content;
                            },
                        }).on('success', function (e) {//复制成功响应
                            jerp.pxmu.toast(mes);
                        }).on('error', function (e) {//复制失败响应
                            jerp.pxmu.toast('复制失败，请联系管理员...');
                        });
                    } else {
                        jerp.pxmu.toast('复制内容为空！');
                    }
                },
                // 全局下载按钮
                downloadCSV: function (content, name) {
                    let uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(content);
                    // 通过创建a标签实现
                    let link = document.createElement("a");
                    link.href = uri;
                    // 对下载的文件命名
                    link.download = name + jerp.getFormatDate(new Date(), 'yyyyMMddHHmmss') + ".csv";
                    link.click();
                },
                getFormatDate: function (t = new Date(), fmt = 'yyyy-MM-dd') {// yyyy-MM-dd HH:mm:ss
                    // let t = new Date();
                    var o = {
                        "M+": t.getMonth() + 1, //月份 
                        "d+": t.getDate(), //日 
                        "H+": t.getHours(), //小时 
                        "m+": t.getMinutes(), //分 
                        "s+": t.getSeconds(), //秒 
                        "q+": Math.floor((t.getMonth() + 3) / 3), //季度 
                        "S": t.getMilliseconds() //毫秒 
                    };
                    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (t.getFullYear() + "").substr(4 - RegExp.$1.length));
                    for (var k in o) {
                        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    }
                    return fmt;
                },
                // 每个月有多少天
                monthHasDays: function (t) {
                    return new Date(new Date(t).setDate(0)).getDate();
                },
                // 等待/休眠，用于请求发起后。防止请求速度过快端口被封
                sleep: function (ms = jerp.delay()) {
                    return new Promise(resolve => setTimeout(resolve, ms));
                },
                // json拼接到url
                jsonToUrlParam: function (json) {
                    return new URLSearchParams(json).toString();
                },
                /** 通用数据请求方法
                 * @param {*} param1 自定义参数 url,api_name,title等 return表明了返回的数据 一般结构为;data=>e.data;list=>e.data.list
                 * @param {*} param2 传参
                 * @returns 
                 */
                getData: function (param1, param2, isJson = false, getAll = true, list = []) {
                    let self = this;
                    // console.log('getAll: ', getAll);
                    // return;
                    return new Promise(resolve => {
                        let p1 = {}, reType = (param1.return != undefined ? param1.return : 'data.list').split('.');
                        if (param1.api_name) p1.api_name = param1.api_name;
                        if (param1._t) p1._t = Math.round(new Date());

                        let $ajaxParam = {
                            url: location.origin + param1.url,
                            method: param1.method ? param1.method : 'post',
                            headers: {
                                'companyid': self.jerpSetting.userInfos[self.jerpSetting.currentUser].companyId,
                                'trackid': 'trackid' + new Date().getTime() + '_' + Math.random().toFixed(5).slice(-5).toString(),
                            },
                            dataType: 'json',
                            data: { ...p1, ...param2 },
                        }
                        let pageSize = param2.pageSize ? param2.pageSize : (param2.page ? param2.page.pageSize : null),
                            pageNo = param2.pageNo ? param2.pageNo : (param2.page ? param2.page.pageNo : null);
                        if (param1.title) {
                            self.pxmu.showload((param1.title ? param1.title : '数据加载中……') + (pageNo ? '(' + pageNo + ')' : ''));
                        }

                        if (isJson) {
                            $ajaxParam.contentType = "application/json;charset=UTF-8";
                            $ajaxParam.data = JSON.stringify($ajaxParam.data);
                        }
                        if (param1.headers) {
                            $ajaxParam.headers = { ...$ajaxParam.headers, ...param1.headers }
                        }
                        $.ajax({
                            ...$ajaxParam,
                            ...{
                                success: function (e) {
                                    // console.log('e0: ', e);
                                    if (e && e.clueId) {
                                        let data = e, flag = true;
                                        for (let i in reType) {
                                            data = data[reType[i]];
                                            // console.log('data:', data);
                                            if (data == undefined) {
                                                flag = false;
                                                break;
                                            }
                                        }
                                        // console.log('flag:', flag);
                                        if (flag) {
                                            if (Array.isArray(data)) {
                                                list = [...list, ...data];
                                            } else {
                                                if (Object.keys(list).length == 0) list = {};
                                                list = { ...list, ...data };
                                            }
                                            if (getAll &&
                                                (data != undefined && data != null) &&
                                                (pageNo != null && pageSize != null) &&
                                                (pageSize && data.length == pageSize)
                                            ) {
                                                if (param2.pageNo) param2.pageNo += 1;
                                                if (param2.page && param2.page.pageNo) param2.page.pageNo += 1;
                                                resolve(jerp.getData(param1, param2, isJson, getAll, list));
                                            } else {
                                                resolve(list);
                                            }
                                        } else {
                                            resolve(e);
                                        }
                                    } else {
                                        resolve(e);
                                    }
                                },
                                error: function (e) {
                                    console.log(e);
                                    resolve(list);
                                }
                            }
                        })
                    })
                },
                /**
                 * 获取商品最新采购单
                 * @param {*} goodsInfo {outerId,title}
                 * @returns 
                 */
                getLastPurchaseOrder: async function (goodsInfo) {
                    let searchParam = {
                        api_name: 'caigou_purchase_list',
                        pageNo: 1,
                        pageSize: 5,
                        showExpireDeliveryDateOnly: 0,
                        timeType: 'created',
                        queryType: 'title',
                        // timeEnd: Math.round(new Date()),
                        // timeStart: Math.round(new Date('2022-1-1')),
                        outerIdQueryType: 0,
                        quantityType: 'quantity',
                        withStatsInfo: true,
                        status: 'STATUS_ALL',
                    };
                    return new Promise((resolve, reject) => {
                        $.ajax({
                            url: location.origin + '/caigou/purchase/list',
                            method: 'get',
                            dataType: 'json',
                            // async: false,
                            data: { ...searchParam, ...{ outerId: goodsInfo.outerId } },
                            success: function (e) {
                                if (e && e.suc) {
                                    resolve(e.data.list);
                                } else {
                                    resolve();
                                }
                            },
                            error: function (e) {
                                jerp.pxmu.toast(e.message);
                                console.log(e.message);
                                resolve();
                            }
                        });
                    }).then(data => {
                        return new Promise(resolve => {
                            // jerp.sleep(jerp.delay());
                            if (!data || data.length == 0) {
                                $.ajax({
                                    url: location.origin + '/caigou/purchase/list',
                                    method: 'get',
                                    dataType: 'json',
                                    // async: false,
                                    data: { ...searchParam, ...{ queryText: goodsInfo.title } },
                                    success: function (e) {
                                        if (e && e.suc) {
                                            resolve(e.data.list);
                                        } else {
                                            jerp.pxmu.toast(e.message);
                                            resolve();
                                        }
                                    },
                                    error: function (e) {
                                        jerp.pxmu.toast(e.message);
                                        resolve();
                                    }
                                });
                            } else {
                                resolve(data);
                            }
                        });
                    }).then(data => {
                        return new Promise(resolve => {
                            // jerp.sleep(jerp.delay());
                            let purchase = { id: '', code: '', deliveryDate: '', supplierId: '', supplierName: '', purchasePrice: '' };
                            if (data && data.length > 0) {
                                const map = new Map();
                                let newData = data.filter(v => !map.has(v.id) && map.set(v.id, v)
                                    && v.status != 'STATUS_WAIT_VERIFY'  // '草稿'
                                    && v.status != 'STATUS_CLOSED'  // '已关闭'
                                    && v.status != 'WAIT_VERIFY'  // '草稿'
                                    && v.status != 'GOODS_CLOSED' // '已关闭'
                                    && v.status != 'VERIFYING' // '待审核'
                                );
                                newData.sort((a, b) => { return a.deliveryDate < b.deliveryDate; });
                                let sp = [];
                                let tb = [];
                                for (let i = 0; i < newData.length; i++) {
                                    let h = newData[i];
                                    if (h.supplierName.indexOf('淘宝') > -1) {
                                        tb.push(h);
                                    } else {
                                        sp.push(h);
                                    }
                                }
                                purchase = {
                                    id: sp.length > 0 ? sp[0].id : tb.length > 0 ? tb[0].id : '',
                                    code: sp.length > 0 ? sp[0].code : tb.length > 0 ? tb[0].code : '',
                                    deliveryDate: sp.length > 0 ? sp[0].deliveryDate : tb.length > 0 ? tb[0].deliveryDate : '',
                                    supplierId: sp.length > 0 ? sp[0].supplierId : tb.length > 0 ? tb[0].supplierId : '',
                                    supplierName: sp.length > 0 ? sp[0].supplierName : tb.length > 0 ? tb[0].supplierName : '',
                                    purchasePrice: '',
                                };
                                // console.log(purchase.id);
                                if (purchase.id != '') {
                                    $.ajax({
                                        url: location.origin + '/caigou/purchase/detail',
                                        method: 'get',
                                        dataType: 'json',
                                        // async: false,
                                        data: {
                                            api_name: 'caigou_purchase_detail',
                                            id: purchase.id,
                                            lessAndMore: 0,
                                            edit: true,
                                            noMerge: true,
                                            withReceiveInfo: true,
                                            diffPriceCompareToLast: false,
                                            pageSize: 1,
                                        },
                                        success: function (e) {
                                            if (e && e.suc) {
                                                let ds = e.data.details;
                                                for (let j = 0; j < ds.length; j++) {
                                                    let d = ds[j];
                                                    if (d.outerId == goodsInfo.outerId) {
                                                        purchase.purchasePrice = d.purchasePrice / 100;
                                                        break;
                                                    }
                                                }
                                                // console.log(purchase.purchasePrice);
                                                // console.log('采购单: ', purchase);
                                                resolve(purchase);
                                            }
                                        },
                                        error: function (e) {
                                            console.log("error", e);
                                            resolve(purchase);
                                        }
                                    });
                                } else {
                                    resolve(purchase);
                                }
                            } else {
                                for (let i in purchase) {
                                    purchase[i] = null;
                                }
                                resolve(purchase);
                            }
                        });
                    })
                },
                /**
                 * 获取库存
                 * @param {*} param {outerId, title, isSuits}
                 * @returns 
                 */
                getGoodsStock: function (param) {
                    return new Promise(resolve => {
                        let mainStockNum = 0, stockTotal = 0;
                        $.ajax({
                            // url: location.origin + '/stock/list/warehouse', // 无法查看套件库存
                            url: location.origin + '/stock/queryListV2',
                            method: 'post',
                            dataType: 'json',
                            // async: false,
                            data: {
                                api_name: 'stock_queryListV2',
                                flag: param.isSuits ? 1 : 0, // 1, // 0:普通商品 1:套件
                                searchPercentage: 'skuLevelStockWarnDiffF',
                                mainOuterId: param.outerId,
                                // text: param.title,
                                // queryType: 'itemName',
                                searchType: 0,
                                tagQueryType: 0,
                                userId: -1,
                                outerIdLike: true,
                            },
                            success: function (e) {
                                let sLists = {}, main = { source: '', num: 0 };
                                if (e.data.list && e.data.list.length > 0) {
                                    let data = e.data.list[0];
                                    // detail4TotalStockList: 仓库列表
                                    for (let i = 0; i < data.detail4TotalStockList.length; i++) {
                                        let d = data.detail4TotalStockList[i];
                                        sLists[d.source] = {
                                            warehouseId: d.warehouseId,
                                            num: 0
                                        }
                                        if (d.warehouseId == jerp.mainStockId) {
                                            main.source = d.source;
                                        }
                                    }
                                    // detail4AvailableStockList: 仓库可用数列表
                                    for (let i = 0; i < data.detail4AvailableStockList.length; i++) {
                                        let d = data.detail4AvailableStockList[i];
                                        sLists[d.source].num = d.num;
                                        stockTotal += d.num;
                                        if (main.source == d.source) {
                                            main.num = d.num;
                                        }
                                    }
                                }
                                resolve({ mainStockNum: main.num, stockTotal });
                            },
                            error: function (e) {
                                resolve({ mainStockNum, stockTotal });
                            }
                        })
                    });
                },
                /**
                 * 获取商品货位
                 * @param {*} outerId 商品id
                 * @param {*} warehouseId 仓库id
                 * @returns 
                 */
                getGoodsCodeByCache: function (outerId, warehouseId = jerp.mainStockId) {
                    if (jerp.goodsCodeCache[outerId] == undefined) {
                        let codes = [];//jerp.getGoodsCode(outerId, warehouseId);
                        $.ajax({
                            url: location.origin + '/wms/goodsSectionInventory/list',
                            method: 'post',
                            dataType: 'json',
                            // async: false,
                            contentType: "application/json;charset=UTF-8",
                            async: false,
                            data: JSON.stringify({
                                api_name: "wms_goodsSectionInventory_list",
                                availableNumEnd: "",
                                availableNumStart: "",
                                batchNo: "",
                                cIds: [],
                                categoryNameStr: "",
                                cid: "",
                                expireDateEnd: "",
                                expireDateStart: "",
                                goodsSectionCode: "",
                                hasBatch: "",
                                hasProduct: "",
                                isAccurate: "0",
                                isExcep: "",
                                mainOuterId: outerId,
                                multiCode: "",
                                page: { pageNo: 1, pageSize: 50 },
                                pageNo: 1,
                                pageSize: 50,
                                productTimeEnd: "",
                                productTimeStart: "",
                                qualityTypes: [],
                                queryMainOuterIdType: "0",
                                queryOuterIdType: "0",
                                queryParams: [{ queryType: "title", queryText: "" }, { queryType: "propertiesName", queryText: "" }],
                                queryText: "",
                                queryType: "propertiesName",
                                shipperIds: "",
                                stockRegionIds: "",
                                stockRegionType: "",
                                supplierIds: [],
                                supplierNames: "",
                                text: "",
                                userIds: "-1",
                                warehouseId: warehouseId,

                                // "userId": -1,
                                // "warehouseId": warehouseId,
                                // "stockRegionId": "",
                                // "goodsSectionCode": "",
                                // "text": outerId, // 商品编码
                                // "queryOuterIdType": "1",
                                // "queryParams": [
                                //     {
                                //         "queryType": "title",
                                //         "queryText": "" // 商品名称
                                //     },
                                //     {
                                //         "queryType": "propertiesName",
                                //         "queryText": ""
                                //     }
                                // ],
                                // "supplierNames": "",
                                // "supplierIds": [],
                                // "categoryNameStr": null,
                                // "multiCode": "",
                                // "stockRegionType": "",
                                // "productTimeStart": "",
                                // "productTimeEnd": "",
                                // "batchNo": "",
                                // "hasBatch": "",
                                // "hasProduct": "",
                                // "page": {
                                //     "pageNo": 1,
                                //     "pageSize": "50"
                                // }
                            }),
                            success: function (e) {
                                if (e && e.suc && e.result == 1 && e.data.list.length > 0) {
                                    // console.log("货位: ", e.data.list);
                                    for (let i = 0; i < e.data.list.length; i++) {
                                        let d = e.data.list[i];
                                        if (d.sku.outerId == outerId) {
                                            codes.push(d);
                                        }
                                    }
                                    // l = r.toString();
                                }
                                // resolve(r);
                            },
                            error: function (e) {
                                // resolve(r);
                            }
                        })
                        // console.log(codes, codes.length);
                        if (codes.length > 0) {
                            let cList = [];
                            for (let i = 0; i < codes.length; i++) {
                                // console.log(codes[i]);
                                cList.push(codes[i].code);
                            }
                            jerp.goodsCodeCache[outerId] = cList;
                        } else {
                            jerp.goodsCodeCache[outerId] = ["Z-Z-Z-Z-Z"];
                        }
                    }
                    return jerp.goodsCodeCache[outerId];
                },
                // getGoodsCode后面就不用了
                getGoodsCode: function (outerId, warehouseId = jerp.mainStockId) {
                    // console.log("商品编码：", outerId);
                    return new Promise(resolve => {
                        let r = [];
                        $.ajax({
                            url: location.origin + '/wms/goodsSectionInventory/list',
                            method: 'post',
                            dataType: 'json',
                            // async: false,
                            contentType: "application/json;charset=UTF-8",
                            data: JSON.stringify({
                                api_name: "wms_goodsSectionInventory_list",
                                availableNumEnd: "",
                                availableNumStart: "",
                                batchNo: "",
                                cIds: [],
                                categoryNameStr: "",
                                cid: "",
                                expireDateEnd: "",
                                expireDateStart: "",
                                goodsSectionCode: "",
                                hasBatch: "",
                                hasProduct: "",
                                isAccurate: "0",
                                isExcep: "",
                                mainOuterId: outerId,
                                multiCode: "",
                                page: { pageNo: 1, pageSize: 50 },
                                pageNo: 1,
                                pageSize: 50,
                                productTimeEnd: "",
                                productTimeStart: "",
                                qualityTypes: [],
                                queryMainOuterIdType: "0",
                                queryOuterIdType: "0",
                                queryParams: [{ queryType: "title", queryText: "" }, { queryType: "propertiesName", queryText: "" }],
                                queryText: "",
                                queryType: "propertiesName",
                                shipperIds: "",
                                stockRegionIds: "",
                                stockRegionType: "",
                                supplierIds: [],
                                supplierNames: "",
                                text: "",
                                userIds: "-1",
                                warehouseId: warehouseId,

                                // "userId": -1,
                                // "warehouseId": warehouseId,
                                // "stockRegionId": "",
                                // "goodsSectionCode": "",
                                // "text": outerId, // 商品编码
                                // "queryOuterIdType": "1",
                                // "queryParams": [
                                //     {
                                //         "queryType": "title",
                                //         "queryText": "" // 商品名称
                                //     },
                                //     {
                                //         "queryType": "propertiesName",
                                //         "queryText": ""
                                //     }
                                // ],
                                // "supplierNames": "",
                                // "supplierIds": [],
                                // "categoryNameStr": null,
                                // "multiCode": "",
                                // "stockRegionType": "",
                                // "productTimeStart": "",
                                // "productTimeEnd": "",
                                // "batchNo": "",
                                // "hasBatch": "",
                                // "hasProduct": "",
                                // "page": {
                                //     "pageNo": 1,
                                //     "pageSize": "50"
                                // }
                            }),
                            success: function (e) {
                                if (e && e.suc && e.result == 1 && e.data.list.length > 0) {
                                    // console.log("货位: ", e.data.list);
                                    for (let i = 0; i < e.data.list.length; i++) {
                                        let d = e.data.list[i];
                                        if (d.sku.outerId == outerId) {
                                            r.push(d);
                                        }
                                    }
                                    // l = r.toString();
                                }
                                resolve(r);
                            },
                            error: function (e) {
                                resolve(r);
                            }
                        })
                    });
                },
                /**
                 * 获取订单
                 * @param {*} param 请求条件
                 * @param {*} pageSize 默认200
                 * @returns 
                 */
                getOrders: function (param, pageSize = 200, pageNo = 1, orders = []) {
                    return new Promise(resolve => {
                        console.log('pageNo: ', pageNo);
                        $.ajax({
                            url: location.origin + '/trade/search',
                            method: 'post',
                            dataType: 'json',
                            // async: false,
                            data: {
                                ...param, ...{
                                    pageNo: pageNo,
                                    pageSize: pageSize
                                }
                            },
                            success: function (e) {
                                if (e && e.clueId && e.data.list) {
                                    orders = [...orders, ...e.data.list];
                                    if (e.data.list.length == pageSize) {
                                        resolve(jerp.getOrders(param, pageSize, pageNo + 1, orders));
                                    } else {
                                        resolve(orders);
                                    }
                                } else {
                                    resolve(orders);
                                }
                            },
                            error: function (e) {
                                resolve(orders);
                            }
                        })
                    })
                },
                /**
                 * 获取订单详情，注意：该方法自带getOrders
                 * @param {*} param 请求条件
                 * @param {*} pageSize 每次请求数据量，默认200
                 * @returns 
                 */
                getOrderDetails: function (param, pageSize = 200) {
                    return new Promise(async resolve => {
                        let orders = await jerp.getOrders(param, pageSize);
                        if (orders.length > 0) {
                            let sids = [];
                            for (let i = 0; i < orders.length; i++) {
                                sids.push(orders[i].b);
                            }
                            let r = await jerp.func_getOrderDetails_2(sids, pageSize);
                            resolve(r);
                        } else {
                            resolve([]);
                        }
                    })
                },
                /**
                 * 获取订单详情，由getOrderDetails发起
                 * @param {*} sids 订单号
                 * @param {*} pageSize 每次请求数据量，默认200
                 * @returns 
                 */
                func_getOrderDetails_2: function (sids, pageSize = 200, pageNo = 1, orders = []) {
                    return new Promise(resolve => {
                        $.ajax({
                            url: location.origin + '/trade/search/sids',
                            method: 'post',
                            dataType: 'json',
                            async: false,
                            data: {
                                api_name: 'trade_search_sids',
                                useHasNext: 1,
                                order: 'desc',
                                sids: sids.toString(),
                                withStock: true,
                                field: 'pay_time',
                                minutesAfterPaidOrderAreNotDisplayed: 0,
                                pageNo: pageNo,
                                pageSize: pageSize,
                            },
                            success: function (e) {
                                if (e && e.clueId && e.data.list) {
                                    orders = [...orders, ...e.data.list];
                                    if (e.data.list.length == pageSize) {
                                        orders = jerp.func_getOrderDetails_2(sids, pageSize, pageNo + 1, orders);
                                    }
                                }
                                resolve(orders);
                            },
                            error: function (e) {
                                resolve(orders);
                            }
                        })
                    })
                },
                /**
                 * 
                 * @param {*} param 
                 * sid: 系统订单号
                 * content: 备注关键词,
                 * operateTimeStart: 开始时间,
                 * operateTimeEnd: 结束时间 可以为空,
                 */
                getOrderTraces: function (param, pageSize = 200, pageNo = 1, traces = []) {
                    return new Promise(resolve => {
                        $.ajax({
                            url: location.origin + '/trade/trace/queryList',
                            method: 'post',
                            dataType: 'json',
                            // async: false,
                            data: {
                                // sids: ,
                                // shortIds: ,
                                // operators: ,
                                // action: ,
                                // operateTimeStart: 1727770874000,
                                // operateTimeEnd: ,
                                ...param, ...{
                                    api_name: 'trade_trace_queryList',
                                    root: 'trade',
                                    app: 'orderOperationLog',
                                    pageNo: pageNo,
                                    pageSize: pageSize,
                                    content: '扣减货位库存',
                                    _noDefaultST: 1,
                                    _t: new Date().getTime(),
                                }
                            },
                            success: function (e) {
                                if (e && e.clueId && e.data.list) {
                                    traces = [...traces, ...e.data.list];
                                    if (e.data.list.length == pageSize) {
                                        resolve(jerp.getOrderTraces(param, pageSize, pageNo + 1, traces));
                                    } else {
                                        resolve(traces);
                                    }
                                } else {
                                    resolve(traces);
                                }
                            },
                            error: function (e) {
                                resolve(traces);
                            }
                        })
                    })
                },
                /**
                 * 获取销售报表
                 * @param {*} param 请求条件
                 * @param {*} pageSize 每次请求数据量，默认200
                 * @returns 
                 */
                getSalesReport: function (param, pageSize = 200, pageNo = 1, orders = []) {
                    return new Promise((resolve, reject) => {
                        $.ajax({
                            url: location.origin + '/trade/search',
                            method: 'post',
                            dataType: 'json',
                            async: false,
                            data: {
                                ...param, ...{
                                    pageNo: pageNo,
                                    pageSize: pageSize
                                }
                            },
                            success: function (e) {
                                if (e && e.clueId && e.data.list) {
                                    orders = [...orders, ...e.data.list];
                                    if (e.data.list.length == pageSize) {
                                        orders = jerp.getSalesReport(param, pageSize, pageNo + 1, orders);
                                    }
                                }
                                resolve(orders);
                            },
                            error: function (e) {
                                reject(orders);
                            }
                        })
                    })
                },
                /**
                 * 文本格式转换，用于将单号、快递号转换为erp支持的格式。
                 * @param {*} str 
                 * @returns 
                 */
                strProcessing: function (str) {
                    if (str) {
                        // str = str.replace(/\ +/g, ""); // 去掉空格
                        str = str.replace(/\n(\n)*( )*(\n)*\n/g, ','); // 去掉空行
                        str = str.replace(/[\r\n]/g, ","); // 回车转,
                        // str = str.replace(/-/g, ""); // -转,
                        // str = str.replace(/_/g, ""); // _转,
                        // ^[\t]*\n
                    }
                    return str;
                },
                title2outerId: function (oTitle) {
                    oTitle = oTitle.replace(/重/g, "ZZ");
                    oTitle = oTitle.replace(/根母/g, "LM");
                    oTitle = oTitle.replace(/四通/g, "4T");
                    oTitle = oTitle.replace(/\ +/g, "");
                    oTitle = oTitle.replace(/\++/g, "P");
                    oTitle = oTitle.replace(/\-+/g, "H");
                    // console.log(1,oTitle);
                    oTitle = oTitle.replace(/\Φ/g, "FAI");
                    oTitle = oTitle.replace(/\φ/g, "FAI");
                    // console.log(6,oTitle);
                    oTitle = oTitle.replace(/\*/g, "M");
                    // console.log(7,oTitle);
                    oTitle = oTitle.replace(/\./g, "D");
                    // console.log(8,oTitle);
                    oTitle = oTitle.replace(/\-/g, "TO");
                    // console.log(9,oTitle);
                    oTitle = oTitle.replace(/\~/g, "TO");
                    // console.log(10,oTitle);
                    // oTitle = oTitle.replace(/[`~!@#$%^&*()_\+=<>?:\"{}\(\)|,.\\/;\'\\\\[\]·~！@#￥%……&*（）——\-+=|《》？：“”【】、；‘’，。、]/g, "");
                    // oTitle = oTitle.replace(/[`~!@#$%^&()_\+=<>?:\"{}\(\)|,.\\/;\'\\\\[\]·~！@#￥%……&（）——+=|《》？：“”【】、；‘’，。、]/g, "");
                    oTitle = oTitle.replace(/[\(\),，（）]/g, "");
                    // console.log(11,oTitle);
                    return ('BXG' + pinyin.getCamelChars(oTitle)).toUpperCase();
                },
                /**
                 * 获取指定标签的订单
                 * @param {*} specifiedLabels tagIds:标签id，用英文逗号隔开
                 * 3654052177370061: 打单未发货
                 * 4852919152027232: 低于成本价
                 * 4854052524613986: 境外订单
                 */
                getOrdersWithSpecifiedLabels: function (specifiedLabels, pageNo = 1, list = []) {
                    let self = this;
                    $.ajax({
                        url: location.origin + '/trade/search',
                        method: 'post',
                        dataType: 'json',
                        async: false,
                        data: {
                            api_name: 'trade_search',
                            useHasNext: 1,
                            queryId: 62,
                            order: 'desc',
                            _t: Math.round(new Date()),
                            containMemo: '',
                            timeType: 'pay_time',
                            tagIds: specifiedLabels,
                            pageNo: pageNo,
                            pageSize: 50,
                            field: 'pay_time',
                            needOrder: 0,
                            useCompress: 1,
                            minutesAfterPaidOrderAreNotDisplayed: 0,
                        },
                        success: function (e) {
                            if (e && e.clueId) {
                                if (e.data.list && e.data.list.length > 0) {
                                    list = self.getOrdersWithSpecifiedLabels(specifiedLabels, pageNo + 1, [...list, ...e.data.list]);
                                }
                            }
                        },
                        error: function (e) {
                            console.log("error", e);
                        }
                    });
                    return list;
                },
                /**
                 * 为订单清除指定标签
                 * @param {*} specifiedLabels tagIds:标签id，用英文逗号隔开
                 */
                OrderSpecifiedLabelsClear: function (specifiedLabels) { },
                /**
                 * 为订单清空标签
                 * @param {*} specifiedLabels tagIds:标签id，用英文逗号隔开
                 */
                OrderSpecifiedLabelsClearAll: function (sids, specifiedLabels) {
                    let suc = false;
                    $.ajax({
                        url: location.origin + '/trade/tag/addOrCover',
                        method: 'post',
                        dataType: 'json',
                        async: false,
                        data: {
                            api_name: 'trade_tag_addOrCover',
                            flag: 2,
                            updateTagIds: specifiedLabels,
                            sids: sids
                        },
                        success: function (e) {
                            if (e && e.clueId && e.result == 1) {
                                suc = true;
                            }
                        },
                        error: function (e) {
                            console.log("error", e);
                        }
                    });
                    return suc;
                },
                /**
                 * 为订单添加标签
                 * @param {*} specifiedLabels  tagIds:标签id，用英文逗号隔开
                 */
                OrdersAddSpecifiedLabels: function (sids, specifiedLabels) {
                    let suc = false;
                    $.ajax({
                        url: location.origin + '/trade/tag/addOrCover',
                        method: 'post',
                        dataType: 'json',
                        async: false,
                        data: {
                            api_name: 'trade_tag_addOrCover',
                            flag: 1,
                            updateTagIds: specifiedLabels,
                            sids: sids,
                        },
                        success: function (e) {
                            if (e && e.clueId && e.result == 1) {
                                suc = true;
                            }
                        },
                        error: function (e) {
                            console.log("error", e);
                        }
                    });
                    return suc;
                }
            }
        });
    }
})();

function importJS(url) {
    let script = document.createElement('script');
    script.setAttribute('type', 'text/javascript');
    script.setAttribute('referrerpolicy', 'no-referrer');
    script.src = url;
    // document.documentElement.appendChild(script);
    document.getElementsByTagName('head').item(0).appendChild(script);
}
function importCSS(url) {
    let style = document.createElement('link');
    style.type = 'text/css';
    style.rel = 'stylesheet';
    style.href = url;
    document.getElementsByTagName('head').item(0).appendChild(style);
}